status: accepted
The checkout transition plan compares migrations by ID and hash, not by path
To decide what to revert before switching branches, checkout loads the migrations of the current and the target commit and compares them by ID and content. A migration is reverted when it is missing on the target or its content differs there. Paths only locate the files. The same comparison against the current commit finds the local edits that stash and checkout --allow-dirty reconcile first.
Content means a fingerprint: the normalized up and down scripts, dependencies, after, rebuild_dependants_of, and the transactional and idempotent flags. Comparing the up script alone would let an edited down script or config through unnoticed, which the earlier path-based plan did catch.
After checkout, mitch restores what it reverted. It finds each migration in the new state by ID; failing that, at the same path, because the config gave the file a new ID; failing that, as a migration with the same fingerprint under an ID the old state did not have, because the file was renamed. The last two fallbacks keep the earlier behaviour for changed IDs and renames. They can match a genuinely new migration that happens to reuse a path or the exact content, which is then applied without --and-up.
The previous plan mapped git diff --name-status paths to migrations. That breaks after a rework: going back to a commit before the rework shows the archived A@1.up.sql as deleted and would revert A with all its dependants, although A is the same migration with the same hash on both commits, just under another path. Comparing identities also removes the special cases the path-based plan needed for changed IDs in configs, added or removed configs, and renamed files.