Skip to content

test(vector-index): resolve the repair migration's parent instead of branch@-1 - #3238

Merged
nicoloboschi merged 1 commit into
mainfrom
fix/vecidx-migration-test-relative-revision
Aug 7, 2026
Merged

test(vector-index): resolve the repair migration's parent instead of branch@-1#3238
nicoloboschi merged 1 commit into
mainfrom
fix/vecidx-migration-test-relative-revision

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Fixes the test-api (1/3) failure that has been red on main for every PR since #3214 merged (seen on #3237, #3235, #3234).

What broke

test_migration_drops_stale_global_index steps below the repair migration before planting a stale global index:

command.downgrade(cfg, "f2a6d8c4b1e9@-1")

f2a6d8c4b1e9@-1 is alembic's branch@relative syntax — it counts back from the head of the branch containing that revision, not from the revision itself. While f2a6d8c4b1e9 was head, that happened to be its parent, so the test worked.

#3214 added b3e8d1c6f4a9 on top of it. @-1 now resolves to f2a6d8c4b1e9 itself, so:

Running downgrade b3e8d1c6f4a9 -> f2a6d8c4b1e9    ← stops ON the repair migration
Running upgrade   f2a6d8c4b1e9 -> b3e8d1c6f4a9    ← the drop never re-runs

The stale index gets planted after the drop has already run, the upgrade never re-runs it, and the assertion fails with assert 1 == 0. The migration under test is fine — only the test's setup was wrong, and any migration landing after the repair would have triggered it.

Fix

Resolve the parent from the revision map:

parent = ScriptDirectory.from_config(cfg).get_revision(_REPAIR_REVISION).down_revision
command.downgrade(cfg, parent)

This cannot rot when the next migration lands on top.

Verified

  • The three tests in the file pass.
  • With DROP INDEX IF EXISTS ... disabled in f2a6d8c4b1e9, the test fails again (assert 1 == 0) — so it still exercises the behaviour it claims to, rather than passing vacuously.
  • lint.sh clean.

…branch@-1

`test_migration_drops_stale_global_index` stepped below the repair migration with
`command.downgrade(cfg, "f2a6d8c4b1e9@-1")`. That is alembic's branch@relative
syntax: it counts back from the *head* of the branch containing the revision, not
from the revision itself. It meant "the parent" only for as long as f2a6d8c4b1e9
was head.

b3e8d1c6f4a9 (#3214) landed on top of it, so `@-1` began resolving to
f2a6d8c4b1e9 itself: the downgrade stopped ON the repair migration, the test
planted the stale index after the drop had already run, and the upgrade never
re-ran it. The test has been failing on main for every PR since — `assert 1 == 0`
— with nothing wrong in the migration it covers.

The parent now comes from the revision map, so the next migration added on top
cannot break it. Verified it still fails when the DROP INDEX is disabled.
@nicoloboschi
nicoloboschi merged commit 3211952 into main Aug 7, 2026
104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant