expand-and-contract
A way to change a live database in safe steps: add the new structure, move data and code to it, then remove the old structure.
In more detail
To split a name column into first and last, you first add the new nullable columns (expand), backfill them from the old one, switch every service to the new columns, and only then drop the old column (contract). Each step works with both the old and the new code, so rolling deployments never break.
Related terms
- database migration — A scripted, versioned change to a database's structure, such as adding a table or a constraint.
- backfill — Filling in data after the fact, such as copying old values into a newly added column or copying a found value into a faster cache.
- zero-downtime deployment — Releasing a new version while users keep being served, with no period where the service is unavailable.
- rolling update — Replacing instances of an application with the new version a few at a time while the rest keep serving.
- schema evolution — Changing the structure of your data over time while keeping existing producers and consumers working.
- breaking change — A change that makes existing users of a program or interface stop working until they change something too.
Taught in
- Database Access & Migrations: ORM & Data Layers — Production Full-Stack Engineering
- Evolving An Event Without Breaking Consumers — Apache Kafka & Event Streaming