Skip to content

Run Alembic migrations on container boot#6

Merged
CaptainCo0L merged 1 commit into
mainfrom
fix-boot-migrations
Jun 29, 2026
Merged

Run Alembic migrations on container boot#6
CaptainCo0L merged 1 commit into
mainfrom
fix-boot-migrations

Conversation

@CaptainCo0L

Copy link
Copy Markdown
Owner

Problem

The Docker image shipped without alembic/ or alembic.ini and booted straight into uvicorn, so migrations never ran. Fresh volumes survived via create_all, but any existing deploy drifted whenever the schema changed — e.g. after the dues/fee PR, POST /api/batches 500'd with column "monthly_fee" of relation "batches" does not exist, which also broke the downstream enrollment / session / payment flows.

Fix

  • Copy alembic/ + alembic.ini into the image.
  • Run alembic upgrade head before uvicorn in the CMD.

Both revisions are idempotent (0001 = create_all, 0002 = guarded add), so this is safe on fresh and stale DBs alike.

Verification

Reproduced the broken state (dropped batches.monthly_fee on a live volume), rebuilt, and booted:

  • Logs show Alembic running 0001 → 0002 on startup.
  • Column restored (numeric(10,2)).
  • Drove the UI with Playwright — 8/8 create flows pass, including the previously-failing Add Batch button and the downstream session/payment flows.

🤖 Generated with Claude Code

The image shipped without alembic/ or alembic.ini and booted straight into
uvicorn, so migrations never ran. Fresh volumes survived via create_all, but
any existing deploy drifted on schema changes — e.g. POST /batches 500'd with
"column monthly_fee does not exist" after the dues/fee PR.

Copy alembic into the image and `alembic upgrade head` before uvicorn. Both
revisions are idempotent (0001 = create_all, 0002 = guarded add), so it's safe
on fresh and stale DBs alike.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@CaptainCo0L CaptainCo0L merged commit 3c11e6b into main Jun 29, 2026
1 check passed
@CaptainCo0L CaptainCo0L deleted the fix-boot-migrations branch June 29, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant