[1.7.x] Fixed #23452 -- Prevented infinite migrations for empty unique/index_together.

Thanks fwkroon for the report.

Backport of 6d5958c7a3 from master