42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
|
|
"""use named constraints
|
||
|
|
|
||
|
|
See https://alembic.sqlalchemy.org/en/latest/naming.html
|
||
|
|
|
||
|
|
Revision ID: f17c7ca9afa4
|
||
|
|
Revises: 62882ef5e3ff
|
||
|
|
Create Date: 2024-05-18 17:06:27.696713+00:00
|
||
|
|
|
||
|
|
"""
|
||
|
|
|
||
|
|
from typing import Sequence
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
# revision identifiers, used by Alembic.
|
||
|
|
revision: str = "f17c7ca9afa4"
|
||
|
|
down_revision: str | None = "62882ef5e3ff"
|
||
|
|
branch_labels: str | Sequence[str] | None = None
|
||
|
|
depends_on: str | Sequence[str] | None = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
|
with op.batch_alter_table("movies") as batch_op:
|
||
|
|
batch_op.create_unique_constraint(batch_op.f("uq_movies_imdb_id"), ["imdb_id"])
|
||
|
|
|
||
|
|
with op.batch_alter_table("users", schema=None) as batch_op:
|
||
|
|
batch_op.create_unique_constraint(batch_op.f("uq_users_imdb_id"), ["imdb_id"])
|
||
|
|
|
||
|
|
# ### end Alembic commands ###
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
|
with op.batch_alter_table("users", schema=None) as batch_op:
|
||
|
|
batch_op.drop_constraint(batch_op.f("uq_users_imdb_id"), type_="unique")
|
||
|
|
|
||
|
|
with op.batch_alter_table("movies", schema=None) as batch_op:
|
||
|
|
batch_op.drop_constraint(batch_op.f("uq_movies_imdb_id"), type_="unique")
|
||
|
|
|
||
|
|
# ### end Alembic commands ###
|