Expand and contract (zero-downtime migrations)
Changing a database schema in backward-compatible steps: add the new shape, migrate code and data, and remove the old shape only later.
Renaming a column in one deploy breaks every running instance of the old code. Instead, expand: add the new column and write to both. Migrate: backfill old rows and switch reads. Contract: once no running code uses the old column, drop it. Each step is safe on its own, so blue-green and canary releases can run old and new code side by side, and every step can be rolled back.
Related terms
- Blue-green deployment: Two identical production environments: the new version goes to the idle one, then traffic switches over, and back if something breaks.
- Canary release: Sending a new version to a small share of traffic first, watching error rates and latency, and widening the rollout only if it holds.
- Feature flags: Switches in code that turn a feature on or off for some or all users without a new deploy.
