db-migration-problems: change an enum, split a table, add a foreign key - #12
Merged
Merged
Conversation
…d a foreign key change-an-enum: widening the CHECK is instant; the first WRITE of the new value is the migration, and the shortcut writes it while r1 still reads. split-a-table: dual write and backfill; the shortcut switches reads once the backfill has started — five steps, the longest route in the collection. add-a-foreign-key: NOT VALID spares the old rows, not the running code; adding it mid-rollout makes the old release's deletes fail, in two steps. writ sql reads CHECK … IN as an enum and REFERENCES as an arrow, as planned; it reads NOT VALID as a plain foreign key (identical output, --strict accepts it) while declining VALIDATE CONSTRAINT — asserted as found. The parent README's "the shortcut is always shorter" is now what was measured: shorter in two of six, never longer. Cross-check 57 -> 63 properties (61 compared); 305 checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #11 (base
on-call-rota). Retarget tomainonce #11 merges.Adds the second batch of
db-migration-problems/: three directories built to the first batch's standard. Each has SQL steps read bywrit sql, a safe plan, a shortcut and a README.change-an-enum/'archived'while r1, which cannot read it, still servesadd-value → deploy-r2 → archive-t1split-a-table/add-a-foreign-key/NOT VALIDmid-rollout, so the old code's deletes now faildeploy-r2 → add-not-validwrit sqlfindings, asserted as they are:CHECK … INbecomes an enumerated type, andREFERENCESbecomes(fk …), as planned.NOT VALIDis read as an ordinary foreign key. The output is identical with or without it,--strictaccepts it, and an orphan row in that file loads without complaint.VALIDATE CONSTRAINTis declined under--strict, so the clause that changes meaning is the one accepted silently. Worth a writ issue:--strictcould declineNOT VALIDtoo, since writ carries a constraint's presence, not its validation state.A correction to the parent README: "the shortcut is always shorter" was not measured. Over all six, the shortest route to a finished migration is shorter in two (
add-a-required-column3 vs 5,rename-a-column8 vs 9) and equal in four. The README now says "never slower", with the numbers.comparereports nothing LOST for any of the six, socheckis the gate.Cross-check: 57 → 63 properties (61 compared).
./run-tests.sh all: 305 checks, 0 failed.🤖 Generated with Claude Code