What is the expand/contract (parallel change) pattern for database migrations?
AdvancedConceptRelease Engineering & Reliability Patterns
Answer
Split breaking schema changes into backward-compatible steps:
- Expand: add the new column or table; old code ignores it.
- Deploy code that writes to both old and new, and backfill existing rows.
- Deploy code that reads from the new.
- Contract: stop writing the old column, then drop it in a later release.
At every step the previous code version still works, so any deploy can be rolled back safely.
More on Release Engineering & Reliability Patterns
Why are releases the biggest source of incidents, and what does SRE do about it?BeginnerWhat is a canary release?BeginnerWhat is progressive delivery?IntermediateShow an Argo Rollouts canary with a Prometheus analysis.AdvancedBlue-green vs canary: when do you choose each?IntermediateWhat are feature flags and how do they improve reliability?Beginner