more robust migrations

This commit is contained in:
2025-06-02 18:58:48 +02:00
parent 4dbaa27cba
commit 5c6c3f436e
51 changed files with 401 additions and 273 deletions

View File

@@ -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 ###