[1.7.x] Fixed #22293 -- Avoided renaming many-to-many tables to themselves.

Fixed this for both implementations of _alter_many_to_many, instead of
in `alter_db_table` itself (more implementations).

Backport of 1edfa155e3 from master