awesome-everything RU
↑ Back to the climb

Databases

Schema migrations: free-recall review

Crux Free-recall prompts across the migrations unit. Answer each in your own words first, then reveal the model answer and compare.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Retrieval beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of recall is what makes the mechanism stick when you are staring at a frozen table at 2 a.m.

Goal

Reconstruct the unit’s core mechanisms — the FIFO lock queue, the PG 11 missing-value trick, NOT VALID/VALIDATE, expand-contract, the WAL-flood backfill, and runner serialisation — without looking back at the lessons.

Recall before you leave
  1. 01
    Why can an instant ALTER TABLE freeze a busy table for 60+ seconds, and what exactly is queuing behind what?
  2. 02
    How does PG 11+ make ADD COLUMN with a constant default instant, and what is the difference for a volatile default?
  3. 03
    Explain the NOT VALID + VALIDATE CONSTRAINT pattern and why it is production-safe where a plain ADD CONSTRAINT is not.
  4. 04
    State the core invariant of expand-contract and walk the six phases of a column rename (username to handle).
  5. 05
    Why does a single-statement backfill flood WAL, what breaks downstream, and what is the batch-size guideline?
  6. 06
    Why do down migrations destroy data in production, why does CREATE INDEX CONCURRENTLY need an advisory lock and a non-transactional annotation alongside it, and what is the right rollback strategy?
Recap

If you could reconstruct each answer from memory, you hold the unit’s spine: the FIFO lock queue means a waiting ACCESS EXCLUSIVE freezes a table behind one slow query, so lock_timeout is mandatory; a constant default is a catalog trick (attmissingval) while volatile defaults still rewrite; NOT VALID + VALIDATE and CREATE INDEX CONCURRENTLY move the heavy scan to SHARE UPDATE EXCLUSIVE so DML keeps running; expand-contract maintains a both-versions-compatible schema superset across a rename; batched backfills bound the WAL flood and replica lag; advisory locks serialise runners and forward migrations — never down migrations — are the production rollback.

Continue the climb ↑Schema migrations: a zero-downtime column rename under load
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.