qfa.cli.migrate#
Run alembic upgrade head under a Postgres advisory lock.
Invoked from entrypoint.sh before uvicorn binds the port, and from
make migrate in dev. Multi-replica safe: the session-scoped advisory
lock serialises concurrent migrators so non-winners wait for the winner
to finish before proceeding.
Run from the project root: Alembic resolves ./alembic.ini from the
current working directory.
Module attributes
Stable 64-bit integer key for the migration advisory lock. |
Functions
|
CLI entry point. |
|
Run |
- qfa.cli.migrate.LOCK_KEY: int = 7424901234567890#
Stable 64-bit integer key for the migration advisory lock.
- async qfa.cli.migrate.run_migrations(db: DatabaseSettings | str) None[source]#
Run
alembic upgrade headunder an advisory lock.The lock is session-scoped: it is released automatically when the holding connection closes, so a crashed migrator cannot leave the keyspace permanently held.
- Parameters:
db (DatabaseSettings | str) – Either full DB settings (preferred, supports Entra token auth) or an explicit SQLAlchemy URL (used by integration tests).