Why Not Just Change It
Renaming a column in one step breaks every running instance of the old code the instant it lands, because deploys are not atomic across many servers. The expand and contract pattern, also called parallel change, makes the schema backward and forward compatible through the rollout.
The Three Phases
- Expand: add the new column or table without removing the old one. The schema now supports both shapes.
- Migrate code and backfill: deploy code that writes to both old and new, and backfill existing rows so the new column is populated.
- Contract: once all instances use the new shape and data is migrated, drop the old column.
Each phase is independently deployable, and at no point does the schema reject the code that any live instance is running.
Why It Is Safe
Because expand only adds, it can never break old code. Contract only runs once nothing reads the old column. Between them the system tolerates a mixed fleet, which is exactly what a rolling deploy produces.
Key idea
Expand and contract splits a breaking schema change into additive expand, backfill with dual writes, and a final contract, so old and new code coexist safely throughout a non atomic deploy.