Skip to Content

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) — applies api/sql/migrations/*.sql in filename order, records each in schema_migrations with 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-db dry-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.

Last updated on