Add unique constraints to tables
This commit is contained in:
parent
e8da46fbc1
commit
1c472c359f
1 changed files with 47 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
||||||
|
"""Add unique constraints
|
||||||
|
|
||||||
|
Revision ID: 006b3990db50
|
||||||
|
Revises: 1ef9c4f3765d
|
||||||
|
Create Date: 2023-12-13 18:55:52.587360
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '006b3990db50'
|
||||||
|
down_revision: Union[str, None] = '1ef9c4f3765d'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('apikey', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||||
|
batch_op.create_unique_constraint(None, ['id'])
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
with op.batch_alter_table('apikey', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='unique')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
Add table
Add a link
Reference in a new issue