Schema changes & migrations (ops pattern)🔒 Pro lesson

Expand/Contract: The Pattern Behind Every Safe Migration

During a deploy, old and new versions of your app run side by side for a while.

If a schema change only the new code understands lands too early or too late, one version breaks. The expand/contract pattern keeps every step compatible with both, so nothing breaks in the overlap.

ProLesson body

Pro members see the rest of this lesson

  • A 4-step state diagram: Expand → Dual-write → Backfill → Contract
  • The full mechanism: what PostgreSQL does internally, in source terms
  • 1 SQL query you can run, each labelled by how it was verified
  • The closing insight, the mistake it prevents, and what it changes in your work

Card required. Cancel before day 7 and you are not charged.

Compare plans

Want to read a full lesson first? Five are free end to end, one from each major track. Start with MVCC internals.

Anchored to postgres/postgres on REL_17_STABLE and cross-checked against the manual for PostgreSQL 15–18. Every query here was run and its output captured on a throwaway PostgreSQL 17.10 lab; corrections are noted inline. §5.6 Modifying Tables in the official docs →

Connected

Where this lesson sits

What comes before, after, and alongside it.

Open in the interactive map →
ShareLinkedInX

Finished a free lesson?

Pro opens the rest of the engine course

You felt one mechanism. Pro is the full bodies, interview depth, and the tracks that build on this session.

FollowSubstackLinkedInnew errors · lab notes · hiring loops