fix(migrations): unbreak main, and stop two sessions sharing a version number - #779
Merged
Conversation
…n number
main is red and CD has stopped deploying for the whole repo. Migration
Replay aborts with:
ERROR: duplicate key value violates unique constraint
"schema_migrations_pkey"
Key (version)=(20260826180000) already exists.
Supabase keys its ledger on the numeric PREFIX of the filename
(supabase_migrations.schema_migrations.version, a PRIMARY KEY), not on
the whole name. Two sessions working in parallel each timestamped a
migration 20260826180000 — mention_queue_all_mentions and
resolve_username_history_rpc — so to the ledger they are one migration,
and replaying them dies.
git cannot catch this. Neither file conflicts with the other: different
names, different contents, no overlapping lines. Only the ledger notices,
and by then it is on main, where it blocks the deploy carrying the fix
each session was waiting on.
Renamed mine to 20260826181500. Nothing else about it changes; the
collision is entirely in the filename.
Then closed the class, because "pick a unique timestamp" is exactly the
kind of instruction that works until two people are typing at once:
scripts/check-migration-versions.mjs fails when any two migrations share
a version prefix, and it runs inside `verify`, so a collision costs one
red PR check instead of a blocked pipeline. Verified by reintroducing a
duplicate and watching it name both files, then passing on a clean tree.
npm run verify green; 2385 tests pass.
Co-Authored-By: Claude Opus 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
main is red and CD has stopped deploying for the whole repo.
Cause
Supabase keys its ledger on the numeric prefix of the filename
(
supabase_migrations.schema_migrations.version, a PRIMARY KEY), not on thewhole name. Two sessions working in parallel each timestamped a migration
20260826180000:20260826180000_mention_queue_all_mentions.sql20260826180000_resolve_username_history_rpc.sqlTo the ledger those are one migration, so the replay aborts.
git cannot catch this. Neither file conflicts with the other — different
names, different contents, no overlapping lines. Only the ledger notices, and by
then it is on main, where it blocks the deploy carrying the fix each session was
waiting on.
Fix
Renamed mine to
20260826181500. Nothing else about it changes; the collisionis entirely in the filename.
Closing the class
"Pick a unique timestamp" is exactly the kind of instruction that works until
two people are typing at once.
scripts/check-migration-versions.mjsfails whenany two migrations share a version prefix and runs inside
verify, so acollision costs one red PR check instead of a blocked pipeline:
Verified by reintroducing a duplicate and watching it name both files, then
passing on a clean tree.
npm run verifygreen; 2385 tests pass.