Adjusted the migrations so they work on the prod db

This commit is contained in:
Jonas Linter
2025-11-19 19:10:25 +01:00
parent 661a6e830c
commit 278d082215
5 changed files with 144 additions and 22 deletions

View File

@@ -178,9 +178,18 @@ def upgrade() -> None:
["room_number"],
unique=False,
)
op.create_index(
op.f("ix_acked_requests_username"), "acked_requests", ["username"], unique=False
)
# Create index on acked_requests if it doesn't exist
connection = op.get_bind()
inspector = sa.inspect(connection)
# Get existing indices on acked_requests
acked_requests_indices = [idx['name'] for idx in inspector.get_indexes('acked_requests')]
# Only create index if it doesn't exist
if "ix_acked_requests_username" not in acked_requests_indices:
op.create_index(
op.f("ix_acked_requests_username"), "acked_requests", ["username"], unique=False
)
# ### end Alembic commands ###