[1.7.x] Fixed #23065 -- Quoted constraint names in SQL generated by migrations.

Backport of 83cd18633f from master
[1.7.x] Fixed #23503 -- Fixed renaming of model with self-referential m2m field.

Backport of 463952d940 from master