Opened 4 years ago
Closed 4 years ago
#32724 closed Bug (wontfix)
Deleting a MTI Child model will leave associated rows in the parent table.
Reported by: | Matthias Dellweg | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Steps to reproduce:
- Create a Parent and a Child model
- Migrate and populate some rows in the Child table
- Delete the Child table, create migrations and migrate
- 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
Note:
See TracTickets
for help on using tickets.
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.