#31255: Migration optimizer retains a 1 RemoveField for FK when deleting 2
models
-------------------------------------+-------------------------------------
Reporter: Palisand | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: | Version: 2.2
Migrations |
Severity: Normal | Keywords: migration,optimizer
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
class ModelA(models.Model):
field1 = models.BooleanField(default=False)
class ModelB(models.Model):
another_field1 = models.TextField(blank=True)
field1 = models.BooleanField(default=False)
related_field = models.ForeignKey(ModelA, on_delete=models.CASCADE)
class ModelC(models.Model):
another_field1 = models.TextField(blank=True)
related_field = models.ForeignKey(ModelA, on_delete=models.CASCADE)
}}}
Removing {{{ModelB}}} and {{{ModelC}}} yields the following migration:
{{{
class Migration(migrations.Migration):
dependencies = [
('analyzer', '0149_modela_modelb_modelc'),
]
operations = [
migrations.RemoveField(
model_name='modelc',
name='related_field',
),
migrations.DeleteModel(
name='ModelB',
),
migrations.DeleteModel(
name='ModelC',
),
]
}}}
It is unclear whether the {{{RemoveField}}} operation is redundant or if a
{{{RemoveField}}} operation for {{{ModelB}}} is missing.
I've confirmed that the {{{RemoveField}}} operation for {{{ModelB}}} is
part of the unoptimized operations set.
--
Ticket URL: <https://code.djangoproject.com/ticket/31255>
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/051.056b2668d91940bf5553960363cdc739%40djangoproject.com.