Forward-only DB migrations + deploy safety
Shipped 2026-05-31
The API now applies schema/data changes through a tracked, forward-only migration runner instead of by hand, with CI and deploy-time guardrails:
- Forward-only runner (
api/scripts/migrate.js,npm run migrate/migrate:pretend) — appliesapi/sql/migrations/*.sqlin filename order, records each inschema_migrationswith a SHA-256 checksum, and aborts if an applied file is later edited. See Database migrations. - Deploy-time safety — migrations run as a DO App Platform Pre-Deploy command before traffic cuts over; a failure keeps the current version live and fires the Slack failure alert.
- Pre-merge validation — PRs labelled
deploy-preview-with-dbdry-run the branch’s migrations against an isolated preview DB (real-schema copy from the latest S3 backup), failing the PR check before a bad migration can reach production.
Runs as a dedicated DB_MIGRATE_USER with DDL privileges, kept separate
from the app’s least-privilege runtime user; credentials live in Infisical
per environment.
- Jira: —
- PR: #650
Last updated on