[Django] #32724: Deleting a MTI Child model will leave associated rows in the parent table.

9 views
Skip to first unread message

Django

unread,
May 7, 2021, 6:44:46 AM5/7/21
to django-...@googlegroups.com
#32724: Deleting a MTI Child model will leave associated rows in the parent table.
--------------------------------------------+------------------------
Reporter: Matthias Dellweg | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
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 |
--------------------------------------------+------------------------
Steps to reproduce:
1. Create a Parent and a Child model
2. Migrate and populate some rows in the Child table
3. Delete the Child table, create migrations and migrate
4. Observe that the Parent table is not empty

In contrast to that, if you remove rows from the Child table (while
existing), the corresponding rows in the Parent table are deleted too.

This bug happens both on forward as well as reversed migrations.

Sample project:
https://github.com/mdellweg/migrationtest

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

Django

unread,
May 7, 2021, 8:20:45 AM5/7/21
to django-...@googlegroups.com
#32724: Deleting a MTI Child model will leave associated rows in the parent table.
----------------------------------+--------------------------------------

Reporter: Matthias Dellweg | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Simon Charette):

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


Comment:

This is expected, if you want to get rid of parent rows you should run a
data migration to remove them prior to deleting your child rows. Parent
rows are not different from any model rows as they are usable in isolation
and the fact you don't use them this way is specific to your application.

In all cases changing this behaviour now would also break backward
compatibility.

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

Reply all
Reply to author
Forward
0 new messages