[Ops] Run database migrations automatically and ordered on deploy #89
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
The documented upgrade flow is
docker compose up -d --buildfollowed by a separate manualmake migrate-safe(README.md:89-90,docs/OPERATIONS.md:88-89). Nothing enforces ordering:depends_onfor backend (docker-compose.yml:49-53) and worker (:72-76) gates only on db/redis health, so both boot and serve against the old schema until the operator remembers to migrate.Current behavior
Between
upandmigrate-safe, the app runs on a mismatched schema — new code querying columns/tables that don't exist yet, surfacing as 500s. A fresh-clone first boot also requires the manual step before the app works at all.Fix / Spec
migrateservice todocker-compose.yml:alembic upgrade head, usingDATABASE_MIGRATE_URL.restart: "no",depends_on: db: condition: service_healthy.backendandworker(andbeat)depends_on: migrate: condition: service_completed_successfullyin addition to their current conditions.make migrate-safeas the manual + pre-migration-backup flow for major upgrades. Decide and document one of:alembic_versionagainst the code's head revision and refuse to serve (clear log namingalembic upgrade head/make migrate-safe) on mismatch.docker-compose.prod.ymloverlays cleanly (the migrate service must exist/behave there too).Acceptance criteria
docker compose up -d --buildreaches healthy with a fully migrated schema, zero manual steps.make migrate-safestill works and is documented for major upgrades.README.md,docs/OPERATIONS.md) to reflect the new flow and the backup decision.References
README.md:89-90,docs/OPERATIONS.md:88-94docker-compose.yml:49-53(backend depends_on),:72-76(worker depends_on)Filed from the July 2026 full-project review.