Add unique constraints and foreign key for user_id in flow table
This commit is contained in:
parent
da9b139801
commit
57c09c3409
1 changed files with 2 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ def upgrade() -> None:
|
||||||
batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
||||||
batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
||||||
batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False)
|
batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False)
|
||||||
batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'])
|
batch_op.create_foreign_key('fk_flow_user_id_user', 'user', ['user_id'], ['id'])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
@ -38,7 +38,7 @@ def downgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
try:
|
try:
|
||||||
with op.batch_alter_table('flow', schema=None) as batch_op:
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
batch_op.drop_constraint(None, type_='foreignkey')
|
batch_op.drop_constraint('fk_flow_user_id_user', type_='foreignkey')
|
||||||
batch_op.drop_index(batch_op.f('ix_flow_user_id'))
|
batch_op.drop_index(batch_op.f('ix_flow_user_id'))
|
||||||
batch_op.drop_column('user_id')
|
batch_op.drop_column('user_id')
|
||||||
batch_op.drop_column('folder')
|
batch_op.drop_column('folder')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue