Fix migration planner to fully understand squashed migrations. And test.