Fixed #23410 -- Avoid unnecessary rollbacks in related apps when migrating backwards.

I think the plan should be [`a4`, `b2`, `a2`, `a3`] (effectively switching `a4` and `b2`).