Skip to content

0003: Migrations run as a one-off deploy job, tested in CI

Status: Accepted

Context

Migrations used to run in the container CMD as well as in a prestart service. With several replicas they ran concurrently, and the tests built the schema with create_all(), so migrations were never exercised.

Decision

  • scripts/prestart.sh (migrate, then idempotent seed) runs once per release as a separate job. The API container only serves traffic.
  • The test suite builds its schema by running every Alembic migration on PostgreSQL 18 and runs alembic check to fail on model/migration drift.

Consequences

Schema changes must be backwards compatible with the running release (expand/contract). A migration that only works with create_all() now fails CI.