[1.7.x] Fixed #23160 -- Correctly rename models with self referential fields.

Thanks to whitews AT gmail for the report.

Backport of cbb29af1aa from master
[1.7.x] Fixed a MySQL test failure introduced by cbb29af1aa.

Seems like unlike other backends MySQL get_constraints fails when dealing
with a non-existing table. refs #23160.

Backport of 1b00738f73 from master