Skip to content

fix(orm): rollback targets only batches this migrator defines - #18

Open
enekos wants to merge 1 commit into
masterfrom
fix-rollback-batch-scope
Open

enekos wants to merge 1 commit into
masterfrom
fix-rollback-batch-scope

Conversation

@enekos

@enekos enekos commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Follow-up to #17 — this commit (22c071a) was pushed to the branch right as the PR was merged, so it missed the merge.

The bug: a batch is written by a single run, but batch numbers are global in the shared _sutegi_migrations table. An app sharing a database with another could pick the other app's newest batch as its rollback(1) victim and die in preflight with "no such migration in code". This is also exactly the flake CI caught on #17's first run: the live-PG suites share one history table by design, and pg_rollback_of_a_failing_down_is_atomic picked up the concurrent no-transaction test's batch.

The fix: candidate batches must contain at least one version the rolling-back migrator defines. A code-deleted migration inside our own batch still errors up front (that's a real can't-roll-back situation); another app's batches are simply out of scope.

Adds rollback_targets_only_this_migrators_batches (two migrators sharing one in-memory DB: B's rollback undoes B's batch, A's newer batch stays applied) and the CHANGELOG line. cargo test -p sutegi-orm --all-features with live PG is green, including six consecutive runs of the pg_migrate suite that previously flaked.

(#17's other red check was the perf gate flagging query_builder_wide +14.2% with head CV at 14% — the diff doesn't touch builder.rs; that's the gate's documented machine-noise sensitivity, and this run should re-measure it.)

A batch is written by a single run, but batch numbers are global in the
shared _sutegi_migrations table — so an app sharing a database with
another could pick the OTHER app's newest batch as its rollback victim
and die in preflight on 'no such migration in code' (surfaced as
cross-suite interference in the live-PG tests, which share one history
table by design). Candidate batches now must contain at least one
version the rolling-back migrator defines; a code-deleted migration
inside our own batch still errors up front.

This branch has not been deployed

No deployments
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