Fix binding token extraction and harden startup concurrency
This commit is contained in:
@@ -6,6 +6,8 @@ from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
from app.config import Settings
|
||||
|
||||
SCHEMA_COMPATIBILITY_LOCK_KEY = 2026030501
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
@@ -62,6 +64,10 @@ async def ensure_schema_compatibility() -> None:
|
||||
"CREATE INDEX IF NOT EXISTS idx_token_bindings_ip ON token_bindings(bound_ip)",
|
||||
]
|
||||
async with engine.begin() as connection:
|
||||
await connection.execute(
|
||||
text("SELECT pg_advisory_xact_lock(:lock_key)"),
|
||||
{"lock_key": SCHEMA_COMPATIBILITY_LOCK_KEY},
|
||||
)
|
||||
for statement in statements:
|
||||
await connection.execute(text(statement))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user