[1.7.x] Fixed #22248 -- Made RenameModel reversible

Backport of cf7a2a000e from master
[1.7.x] Fixed #21794 -- Removed deprecation warning for abstract models outside an app.

Backport of e7b9a58b081299b30f807d5c66f7a5d1940efe4c from master.
[1.7.x] Fixed #23410 -- Avoided unnecessary rollbacks in related apps when migrating backwards.

Backport of ab2819aa7b09d36d9ff24830a9825aa52b87fdb4 from master.
[1.7.x] Formatted model states in autodetector tests

Backport of f17acd59303a27876966927869af7f4bfe38a74a from master.
[1.7.x] Cleaned up and reformatted autodetector tests

Backport of 233165083593baf5f62194f50df26fb830e5f570 from master.