fix: prevent concurrent migrations in multi-worker setup

Add migration version check before running alembic upgrade to prevent
multiple uvicorn workers from running migrations simultaneously.

- Check current vs head revision before running migrations
- Skip migration if already at latest version
- Log current and head revision for debugging
This commit is contained in:
Fusion
2026-05-18 22:35:42 +02:00
parent 843683d579
commit 9fefe289a7
2 changed files with 22 additions and 1 deletions
@@ -11,7 +11,7 @@ from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '0003'
revision: str = '0003_user_configs'
down_revision: Union[str, None] = '0002_refresh_tokens'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None