What is database migration strategy for zero-downtime deployments?

Answer

Achieving zero-downtime migrations requires making schema changes backward-compatible with the running application code. Strategy (expand-contract pattern): Phase 1 (Expand) — add the new column/table as nullable; deploy new app code that writes to both old and new structures. Phase 2 (Migrate) — backfill data in batches (never lock the table with a single UPDATE of millions of rows). Phase 3 (Contract) — remove old column/code once migration is verified. Specific techniques: adding columns is safe; renaming columns requires a multi-step process; removing NOT NULL from a column must be done after backfill; adding indexes concurrently (CREATE INDEX CONCURRENTLY in PostgreSQL) avoids locking.