39 lines
842 B
Python
39 lines
842 B
Python
|
"""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))
|