#27558: Setting db_index=False on existing ForeignKey causes constraint to be
recreated
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: db-indexes, mysql | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ed Morley):
Ah thank you!
Bisecting shows the redundant index issue was fixed as of:
https://github.com/django/django/commit/3f76d1402dac9c2993d588f996dc1c331edbc9a7
Whilst the change to `add_field()` in `django/db/backends/base/schema.py`
might look like a no-op (since the `_field_should_be_indexed()` method in
that file does the same thing as the lines being replaced), it actually
wasn't - since mysql overrides the base `self._field_should_be_indexed()`
with it's own that handles `ForeignKey` properly:
https://github.com/django/django/blob/3f76d1402dac9c2993d588f996dc1c331edbc9a7/django/db/backends/mysql/schema.py#L54-L67
--
Ticket URL: <https://code.djangoproject.com/ticket/27558#comment:3>
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/066.cfcbb145e4b44349760e78a941b96af3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.