diff --git a/alembic/versions/02c89ec39f85_remove_unique_constraints.py b/alembic/versions/02c89ec39f85_remove_unique_constraints.py new file mode 100644 index 0000000..6b2a649 --- /dev/null +++ b/alembic/versions/02c89ec39f85_remove_unique_constraints.py @@ -0,0 +1,38 @@ +"""remove unique constraints + +Revision ID: 02c89ec39f85 +Revises: 2450600b8eaf +Create Date: 2022-10-22 17:13:41.104431 + +""" +from alembic import op +from sqlalchemy.sql import text + + +# revision identifiers, used by Alembic. +revision = '02c89ec39f85' +down_revision = '2450600b8eaf' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + conn = op.get_bind() + + remove_unique_constraints = """ + ALTER TABLE projects + DROP CONSTRAINT projects_tag_key, + DROP CONSTRAINT projects_category_key + """ + conn.execute(text(remove_unique_constraints)) + + +def downgrade() -> None: + conn = op.get_bind() + + add_unique_constraints = """ + ALTER TABLE projects + ADD CONSTRAINT projects_tag_key UNIQUE (tag), + ADD CONSTRAINT projects_category_key UNIQUE (category) + """ + conn.execute(text(add_unique_constraints))