Skip to the content.
Database migration rules (loaded only when migrations are touched)
- Old and new application versions run together during deploys; every migration must work with both.
- Rename or retype columns with expand/contract across deploys, never in one step.
- PostgreSQL: create indexes
CONCURRENTLY; add foreign keys and checks NOT VALID then VALIDATE; set lock_timeout before DDL.
- Backfills run in batches outside the schema migration.
- Include a rollback plan or state that the migration is forward-only.