feat(deploy): run database migrations automatically and ordered on deploy (#89) #162
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/89-auto-migrate-service"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The documented upgrade flow required a separate manual
make migrate-safeafterdocker compose up, and nothing enforced ordering —backend/workergated only on db/redis health, so they booted and served against the old schema until the operator remembered to migrate. Fresh first-boot also required the manual step before the app worked at all.Changes
docker-compose.yml: new one-shotmigrateservice — backend image,command: alembic upgrade head,restart: "no",depends_on: db (service_healthy).backend,worker, andbeatnow alsodepends_on: migrate (service_completed_successfully).docker-compose.dev.yml: overridesmigrateto thebackend-devtarget with the./webapp/backendbind mount, so a freshly-written migration is applied onupfrom live source.README.md,docs/OPERATIONS.md,webapp/CLAUDE.md— routine update is now justgit pull && docker compose up -d --build.Behaviour
migrateexits non-zero and app services do not start — old containers keep running rather than serving a half-migrated schema.questboard_migrateviaDATABASE_MIGRATE_URL(env.py), unchanged.Decision: no auto-backup / no auto-preflight
The automatic path deliberately does not run
db_preflightor take a pre-migration dump —db_preflightby design rejects an empty DB, which would block fresh first-boot.make migrate-saferemains the guarded preflight + backup + migrate flow, documented for major upgrades.Verification
docker compose configanddocker compose -f … -f docker-compose.dev.yml configboth resolve cleanly;backendshowsmigrate: service_completed_successfullyin the merged config.make migratetarget, just run as an ordered one-shot.Closes #89
🤖 Generated with Claude Code