#25614: MigrationAutodetector is too greedy when ForeignKey(on_delete=...) is
changed
--------------------------------------+------------------------
Reporter: jdunck | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
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 |
--------------------------------------+------------------------
Recently I changed the on_delete attributes of many ForeignKeys on a MySQL
database.
This resulted in an auto-detected migration that drops and recreates the
constraint for each FK, despite the effective constraint remaining the
same (e.g. FOREIGN KEY (`modified_by_id`) REFERENCES `common_user`
(`id`); )
The
[https://github.com/django/django/blob/1.8.5/django/db/migrations/autodetector.py#L848
autodetection] just compares the deconstruction.
The
[https://github.com/django/django/blob/1.8.5/django/db/backends/base/schema.py#L486
schema editor] drops the FK and recreates it.
It's not entirely clear to me which part needs to be changed - whether the
deconstruction should not include on_delete, or whether the autodetector
should discard on_delete from consideration, or whether the editor should
check for parameters that actually change the effective FK.
What is clear is that dropping and recreating FKs isn't a fast operation
on large databases, and it would be good to avoid where possible.
--
Ticket URL: <https://code.djangoproject.com/ticket/25614>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.4ac297b4254297b100a7ffb72cc6f797%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.