migrations: Make sure insertion order takes base class foreign keys into consideration.
Merge branch 'master' into stable

* master:
  migrations: Make sure insertion order takes base class foreign keys into consideration.
migrations: An actual fix for the order.
Merge branch 'master' into stable

* master:
  migrations: An actual fix for the order.