Chapter 9 of 10All chapters
Chapter 9 of 10
Changing the schema
Evolving a live database safely.
Migrations
A migration is a recorded change to the structure, stored in version control alongside the code. That makes the schema reproducible on every machine and reviewable like anything else.
- Write the rollback as well, before you need it.
- Adding a column is cheap; renaming or dropping one needs a staged plan.
Deploying without downtime
Add the new column, write to both, backfill, switch reads, then remove the old one. Each step keeps the running application valid, which is the whole point.