Quiz - Migrating a live schema without an outage
A teammate’s PR adds a single index to a 10-million-row table: CREATE INDEX idx_invoices_status ON invoices (status). No application code reads the index, and the schema otherwise keeps working for both the old and new fleets. They route it as a one-deploy change. Why is that still an outage waiting to happen?
CREATE INDEX takes ACCESS EXCLUSIVE and blocks every write (and read) on the table for the whole build — the lock axis fails even though the overlap-window axis passes.CREATE INDEX holds ACCESS EXCLUSIVE for the entire build — minutes of frozen writes on a large table. The fix isn’t the cadence; it’s rewriting the one statement into CREATE INDEX CONCURRENTLY. Passing Q1 and Q3 tells you nothing about Q2.During the migrate step you make the updateInvoice server action write both customerName and customerId in the same update. Why is putting the dual-write inside that shared mutation path the senior move, rather than asking each feature to remember to set both columns?
You’re adding a CHECK (amount_cents >= 0) constraint to the invoices table. Which statements about routing this change are correct? Select all that apply.
ADD CONSTRAINT ... NOT VALID followed by VALIDATE CONSTRAINT ships it in one PR with no blocking scan.NOT VALID is the same as NOT NULL, so adding it permanently forbids null values in the constrained column.NOT VALID then VALIDATE two-step is one PR — the first statement is instant, the second scans under the polite SHARE UPDATE EXCLUSIVE lock. On dirty data you backfill the violators first, which is a migrate step, so it escalates to the cadence. And NOT VALID is a “validate later” flag on a constraint — entirely unrelated to SET NOT NULL, which forbids nulls in a column.Your migrate PR’s preview build is fully green — db:migrate ran clean and CI type-check and tests pass. Why is that still not enough to trust the dual-write, and what closes the gap?
update that sets only the old column type-checks fine, so the type system can’t prove the dual-write path is reached for every mutation — you perform a real mutation through the preview URL, then inspect that exact row in Studio to confirm both columns are populated.customer_name and customer_id are set on that row. The branch already carries production-shaped data, so no manual seeding is needed.Quiz complete
Score by topic