How do I deploy database changes with zero downtime?
Use the expand → migrate → contract pattern:
- Expand — add backward-compatible nullable columns or indexes that old code ignores
- Deploy code that can read both the old and new shape; backfill in measured, restartable batches
- Verify metrics, tests and the rollback path before making the new field mandatory
- Contract later — remove old columns only after every client and job is migrated and the rollback window has expired
Also: one migration owner who serialises schema changes, replay migrations from a clean database in CI, prefer forward-only migrations with a documented roll-forward plan, and take a backup before risky steps. Never run production DDL or data deletion without authorisation and a rollback plan.