Reduce calls to state.render in migrations

`state.render` is actually very long, so this commit easily reduce the
number of times it needs to be called by moving some calls only after
`allowed_to_migrate` was called (to avoid calling render states we won't
need)

And in `allowed_to_migrate`, avoid calling `allow_migrate` if not needed.

No new tests because the full test suit still pass and there is nothing new.
yes it's why it's in another commit. I put this in the same PR because it's related to the same code, but i can do anther one for this