-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(tags-db): add
tag
and study_tag
tables to the db (migration)
- Loading branch information
Showing
6 changed files
with
375 additions
and
75 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
alembic/versions/3c70366b10ea_add_tag_and_study_tag_tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Add tag and study_tag tables | ||
Revision ID: 3c70366b10ea | ||
Revises: 1f5db5dfad80 | ||
Create Date: 2024-02-02 13:06:47.627554 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3c70366b10ea" | ||
down_revision = "1f5db5dfad80" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"tag", | ||
sa.Column("label", sa.String(length=40), nullable=False), | ||
sa.Column("color", sa.String(length=20), nullable=True), | ||
sa.PrimaryKeyConstraint("label"), | ||
) | ||
with op.batch_alter_table("tag", schema=None) as batch_op: | ||
batch_op.create_index(batch_op.f("ix_tag_color"), ["color"], unique=False) | ||
batch_op.create_index(batch_op.f("ix_tag_label"), ["label"], unique=False) | ||
|
||
op.create_table( | ||
"study_tag", | ||
sa.Column("study_id", sa.String(length=36), nullable=False), | ||
sa.Column("tag_label", sa.String(length=40), nullable=False), | ||
sa.ForeignKeyConstraint(["study_id"], ["study.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["tag_label"], ["tag.label"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("study_id", "tag_label"), | ||
) | ||
with op.batch_alter_table("study_tag", schema=None) as batch_op: | ||
batch_op.create_index(batch_op.f("ix_study_tag_study_id"), ["study_id"], unique=False) | ||
batch_op.create_index(batch_op.f("ix_study_tag_tag_label"), ["tag_label"], unique=False) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("study_tag", schema=None) as batch_op: | ||
batch_op.drop_index(batch_op.f("ix_study_tag_tag_label")) | ||
batch_op.drop_index(batch_op.f("ix_study_tag_study_id")) | ||
|
||
op.drop_table("study_tag") | ||
with op.batch_alter_table("tag", schema=None) as batch_op: | ||
batch_op.drop_index(batch_op.f("ix_tag_label")) | ||
batch_op.drop_index(batch_op.f("ix_tag_color")) | ||
|
||
op.drop_table("tag") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
""" | ||
CSS Color Module Level 4 | ||
[Color keywords](https://www.w3.org/TR/css-color-4/#color-keywords) | ||
""" | ||
|
||
COLOR_NAMES = ( | ||
"AliceBlue", | ||
"AntiqueWhite", | ||
"Aquamarine", | ||
"Aqua", | ||
"Beige", | ||
"Bisque", | ||
"Black", | ||
"BlanchedAlmond", | ||
"BlueViolet", | ||
"Blue", | ||
"Brown", | ||
"BurlyWood", | ||
"CadetBlue", | ||
"Chartreuse", | ||
"Chocolate", | ||
"Coral", | ||
"CornflowerBlue", | ||
"Cornsilk", | ||
"Crimson", | ||
"DarkBlue", | ||
"DarkGoldenrod", | ||
"DarkGray", | ||
"DarkGreen", | ||
"DarkKhaki", | ||
"DarkOliveGreen", | ||
"DarkOrange", | ||
"DarkOrchid", | ||
"DarkSalmon", | ||
"DarkSeaGreen", | ||
"DarkSlateBlue", | ||
"DarkSlateGray", | ||
"DarkTurquoise", | ||
"DarkViolet", | ||
"DeepPink", | ||
"DeepSkyBlue", | ||
"DimGray", | ||
"DodgerBlue", | ||
"FireBrick", | ||
"ForestGreen", | ||
"Gainsboro", | ||
"Goldenrod", | ||
"Gold", | ||
"Gray", | ||
"GreenYellow", | ||
"Green", | ||
"Honeydew", | ||
"HotPink", | ||
"IndianRed", | ||
"Indigo", | ||
"Ivory", | ||
"Khaki", | ||
"LavenderBlush", | ||
"Lavender", | ||
"LawnGreen", | ||
"LemonChiffon", | ||
"LightBlue", | ||
"LightCoral", | ||
"LightCyan", | ||
"LightGoldenrod", | ||
"LightGray", | ||
"LightGreen", | ||
"LightPink", | ||
"LightSalmon", | ||
"LightSeaGreen", | ||
"LightSkyBlue", | ||
"LightSlateGray", | ||
"LightSteelBlue", | ||
"LightYellow", | ||
"LimeGreen", | ||
"Lime", | ||
"Linen", | ||
"Magenta", | ||
"Maroon", | ||
"MediumAquamarine", | ||
"MediumBlue", | ||
"MediumOrchid", | ||
"MediumPurple", | ||
"MediumSeaGreen", | ||
"MediumSlateBlue", | ||
"MediumSpringGreen", | ||
"MediumTurquoise", | ||
"MediumVioletRed", | ||
"MidnightBlue", | ||
"MintCream", | ||
"MistyRose", | ||
"Moccasin", | ||
"NavajoWhite", | ||
"Navy", | ||
"OldLace", | ||
"OliveDrab", | ||
"Olive", | ||
"OrangeRed", | ||
"Orange", | ||
"Orchid", | ||
"PaleGoldenrod", | ||
"PaleGreen", | ||
"PaleTurquoise", | ||
"PaleVioletRed", | ||
"PapayaWhip", | ||
"PeachPuff", | ||
"Peru", | ||
"Pink", | ||
"Plum", | ||
"PowderBlue", | ||
"Purple", | ||
"Red", | ||
"RosyBrown", | ||
"RoyalBlue", | ||
"SaddleBrown", | ||
"Salmon", | ||
"SandyBrown", | ||
"SeaGreen", | ||
"Seashell", | ||
"Sienna", | ||
"Silver", | ||
"SkyBlue", | ||
"SlateBlue", | ||
"SlateGray", | ||
"Snow", | ||
"SpringGreen", | ||
"SteelBlue", | ||
"Tan", | ||
"Teal", | ||
"Thistle", | ||
"Tomato", | ||
"Turquoise", | ||
"Violet", | ||
"Wheat", | ||
"WhiteSmoke", | ||
"White", | ||
"YellowGreen", | ||
"Yellow", | ||
) | ||
"""List of CSS4 color names used to style tags.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.