Latest dealsDeals See all deals→
Lesson 2 of 4 · 1 min

The Expand–Contract Pattern

Expand–contract is the workhorse of zero-downtime migrations. The idea is to treat a schema change not as one operation but as four: expand the schema additively, deploy application code that tolerates both the old and the new shape, backfill the new shape from the old one, and finally contract the schema by removing whatever the old shape occupied.

The discipline is that every phase has to be independently safe to roll back. If phase 2 goes wrong, you should be able to revert the application code without touching the database at all. If phase 3 goes wrong, you should be able to stop and restart the backfill without the application noticing. Phase 4 — the destructive one — comes last, and only after the system has been stable on the new shape for long enough that you trust it.

The classic example is a column rename. You add the new column (expand). You update application code to write both columns (deploy). You run a backfill from old to new (backfill). You update code to read the new column. Then — and only then — you drop the old column (contract). It feels like overkill the first time. The third time you do it, it feels like the only way anything ever changes.

More courses

All courses →
Email Marketing

Cold Email That Actually Works

Four lessons on sending the kind of cold email that gets replies instead of deletes.

4 lessons 8 min Self-paced
Lead instructor · Priyanka Iyer · guest instructor from Daniel Park View course
Lessons
  1. Before You Write Anything: The Targeting Work
  2. The Seventy-Word Rule
  3. The Subject Line Isn't What You Think
  4. Deliverability: The Technical Stuff Your Marketer Can't Fix Alone
Food & Cooking

Weeknight Heat and Timing

This course teaches the small set of moves that make most weeknight dinners work: controlling heat, seasoning in stages, building a pan sauce, and turning one pot or sheet pan…

6 lessons 1h 8m Self-paced
Lead instructor · Brooklyn Wilson View course
Lessons
  1. Heat First
  2. Salt in Stages
  3. The Brown Bits Dinner
  4. One Pan, Full Meal
  5. Start with Aromatics
  6. Cook Pasta Like Sauce Matters