Opened 2 years ago

Closed 2 years ago

#33903 closed Bug (needsinfo)

Changing the related_name field causing pointless foreign key re-creations on MySQL migrations

Reported by: Thomas Aitken Owned by: nobody
Component: Migrations Version: 2.2
Severity: Normal Keywords: migrations, foreign key
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

MySQL version = 8.0, Django version = 2.2.28. Each change to a related_name triggers a migration that looks like the following:
ALTER TABLE {table_name} DROP FOREIGN KEY {constraint_name};
ALTER TABLE {table_name} ADD CONSTRAINT {constraint_name} FOREIGN KEY ({other_table_id}) REFERENCES {other_table_name} (id);

In other words, it is pointlessly (?) dropping and creating the same foreign key constraint. Supposedly, this was fixed a long time ago for v2.1 (https://code.djangoproject.com/ticket/25253). But seems like, somehow, it's still present.

Change History (1)

comment:1 by Claude Paroz, 2 years ago

Resolution: needsinfo
Status: newclosed

Django 2.2 is no longer supported. I didn't search the history, but have the strong feeling that this is solved in recent Django versions. Do you have the ability to test with more recent versions?

Note: See TracTickets for help on using tickets.
Back to Top