migrations: Make sure insertion order takes base class foreign keys into consideration.
migrations: An actual fix for the order.