#23101: Changing name of M2MField while db_table keeps table name unchanged
leads
to spurious migration that changes table name
---------------------------------+----------------------
Reporter: maney@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------
This is the terse version, I'm going to revisit this later as I think this
and #22975 share similar root cause: using the apparent/default name and
overlooking the db_table that actually sets the table's name.
In Model "Some", have a field like
x = ManyToManyField("Other") # table name app_some_x
Change that to
x_set = ManyToManyField("Other", db_table="app_some_x")
which doesn't actually change anything in the schema, but the migration
sees it as a rename of the intermediate table, generates a migration, and
changes the name. At this point you can observe in the shell that eg.,
Some.x_set.field.m2m_db_table() -> app_some_x, but the table in the
database has been migrated to app_some_x_set.
(caveat: the above hasn't been tested per se, I'm summarizing to get this
on record before I have to go. Marked as 1.7, but while chatting with
Andrew I did check it against master - no change.)
--
Ticket URL: <https://code.djangoproject.com/ticket/23101>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.d63c6523b6e310acb1739491328439db%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.