[Django] #33903: Changing the related_name field causing pointless foreign key re-creations on MySQL migrations

8 views
Skip to first unread message

Django

unread,
Aug 7, 2022, 4:43:40 AM8/7/22
to django-...@googlegroups.com
#33903: Changing the related_name field causing pointless foreign key re-creations
on MySQL migrations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
ThomasAitken |
Type: Bug | Status: new
Component: | Version: 2.2
Migrations | Keywords: migrations,foreign
Severity: Normal | key
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/33903>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 7, 2022, 4:51:02 AM8/7/22
to django-...@googlegroups.com
#33903: Changing the related_name field causing pointless foreign key re-creations
on MySQL migrations
-------------------------------------+-------------------------------------
Reporter: Thomas Aitken | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 2.2
Severity: Normal | Resolution: needsinfo
Keywords: migrations,foreign | Triage Stage:
key | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* status: new => closed
* resolution: => needsinfo


Comment:

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?

--
Ticket URL: <https://code.djangoproject.com/ticket/33903#comment:1>

Reply all
Reply to author
Forward
0 new messages