more robust migrations
This commit is contained in:
@@ -17,9 +17,15 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col['name'] for col in inspector.get_columns('room_file')]
|
||||
|
||||
with op.batch_alter_table('room_file', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column('deleted_at', sa.DateTime(), nullable=True))
|
||||
if 'deleted_by' not in columns:
|
||||
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
|
||||
if 'deleted_at' not in columns:
|
||||
batch_op.add_column(sa.Column('deleted_at', sa.DateTime(), nullable=True))
|
||||
batch_op.create_foreign_key('fk_room_file_deleted_by_user', 'user', ['deleted_by'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user