Skip to content

fix(cli): order migrations by version - #6038

Merged
avallete merged 3 commits into
supabase:developfrom
7ttp:fix/ts-migration-version-ordering-6036
Aug 3, 2026
Merged

fix(cli): order migrations by version#6038
avallete merged 3 commits into
supabase:developfrom
7ttp:fix/ts-migration-version-ordering-6036

Conversation

@7ttp

@7ttp 7ttp commented Aug 3, 2026

Copy link
Copy Markdown
Member

TL;DR

Fixing db push failing with Remote migration versions not found in local migrations directory
for a version that's sitting right there on disk, which happened because local files arrive in name order while schema_migrations comes back in version order, and
those two disagree whenever one version is a string prefix of another (1 vs 10, or 20260420 vs 20260420010000): 10_b.sql sorts before 1_a.sql ('0' < '_'),
so the two-pointer merge desynchronises and reports an already-applied version as missing. migration up walks the same merge, and migration repair --status reverted is no way out, the versions just come back as ErrMissingRemote...

sorted now by ordering local paths by version before the walk:
a new legacySortMigrationPathsByVersion called from both legacyFindPendingMigrations implementations,
rather than from legacyListLocalMigrations where the name ordering originates that list also feeds the pgdelta cache hash, so reordering it there would drift the cache key. TS shell only, since that's the user-facing path today via legacy....

--include-all needed the same treatment:
it slices the local list at remoteCount + diff.length, so with diff now version-ordered it has to index the version-ordered list too. Left name-ordered it would re-apply an already-applied migration and silently skip a pending one (1,2,20 with 2 applied → [1, 2] instead of [1, 20]).

Refs

@7ttp
7ttp requested a review from a team as a code owner August 3, 2026 08:54
@7ttp 7ttp self-assigned this Aug 3, 2026
@7ttp 7ttp added the migration label Aug 3, 2026
@avallete
avallete added this pull request to the merge queue Aug 3, 2026
Merged via the queue into supabase:develop with commit c2ec9f5 Aug 3, 2026
25 checks passed
7ttp added a commit to 7ttp/cli that referenced this pull request Aug 4, 2026
## TL;DR

Fixing the `parallelStacks.e2e.test.ts` flake that's hit CI three times
now:
always the same pair of `90000ms` + `60000ms` hook timeouts with nothing
useful in the log. Turns out the harness could hang three ways:
a stack that died cleanly never settled its promise (the exit handler
only checked for non-zero), stack that wedged had no timeout at all, and
if one stack failed, its healthy sibling's handle got dropped
so teardown killed nothing and the leak-check spun for 60s chasing a
process it couldn't reach...

The spawn logic now lives in a small `spawnStandaloneStack` helper that
settles on every path with the child's actual output attached, and
teardown tracks children from the moment they spawn.

Also fixed `terminateChildProcess` quietly burning 2×30s on an
already-dead child, that alone would've recreated
the afterAll timeout. Repro'd all three failure modes with stubs first,
each one has a pinning test, and the real suite ran green 6 times in a
row....

## refs

- Deflakes the shard-1/3 failures from the supabase#6038 and supabase#6004 CI runs
- Pairs with supabase#6045 which fixes the underlying startup port race properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

db push fails: 'Remote migration versions not found' when 8-digit and 14-digit migration timestamps share the same prefix

2 participants