Fixed #19657 -- Made sql commands honour allow_migrate

Thanks Manel Clos for the report and the initial patch.
Add get_syncable_models util method to ConnectionRouter