Fixed #21283 -- Added support for migrations if models is a package.

Thanks Markus Holtermann for the report.