#36791: Migration does not drop old M2M through-table when ManyToManyField
target
model changes
-------------------------------------+-------------------------------------
Reporter: Johanan Oppong | Type:
Amoateng | Uncategorized
Status: new | Component: Database
| layer (models, ORM)
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
When changing the target model of a ManyToManyField, the migration
autodetector generates only an AlterField operation. Django does not
create a RemoveField + AddField sequence, and the old automatically
generated through-table is left in place.
This results in the database schema no longer matching the model
definitions. In my case, the stale through-table caused inconsistent M2M
behaviour and errors when interacting with the relationship. No data
records were lost, but the schema was incorrect until manually fixed.
This behaviour appears inconsistent with how Django handles other
destructive schema changes.
--
Ticket URL: <https://code.djangoproject.com/ticket/36791>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019b0ad8be42-7bc620ab-a0b1-4c96-927a-5b8696948b95-000000%40eu-central-1.amazonses.com.