[1.7.x] Fixed #23614 -- Changed the way the migration autodetector orders unique/index_together

Thanks to Naddiseo for the report and Tim Graham for the review

Backport of 5c9c1e029d from master