#31343: Foreign key constraint to MTI child model is lost if the child model's
parent was changed.
-------------------------------------+-------------------------------------
Reporter: Antonis | Owner: nobody
Christofides |
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: duplicate
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 felixxm):
* status: new => closed
* resolution: => duplicate
Comment:
Thanks for this ticket. I think it's another use case for
`AlterModelBases`, see #23521. I was able to migrate this properly with
the following operations:
{{{
operations = [
migrations.CreateModel(
name='CommercialPlace',
fields=[
('place_ptr', models.OneToOneField(auto_created=True,
on_delete=django.db.models.deletion.CASCADE, parent_link=True,
primary_key=True, serialize=False, to='places.Place')),
('business_name', models.CharField(max_length=50)),
],
bases=('places.place',),
),
migrations.AlterModelBases('restaurant',
('places.commercialplace',)),
migrations.RenameField('restaurant', 'place_ptr',
'commercialplace_ptr'),
migrations.AlterField(
model_name='restaurant',
name='commercialplace_ptr',
field=models.OneToOneField(auto_created=True,
on_delete=django.db.models.deletion.CASCADE, parent_link=True,
primary_key=True, serialize=False, to='places.CommercialPlace'),
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31343#comment:1>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/064.f2b7fdc411bb406cad407b2b4689af1a%40djangoproject.com.