Remove unique constraints for tag and category

This commit is contained in:
LoRiot 2022-10-22 17:34:41 +03:00
parent cfcb2b2535
commit d2307dba48

View file

@ -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))