#36632: AlterIndexTogether in historical migration drops overlapping indices
-------------------------------------+-------------------------------------
Reporter: Michael Herrmann | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: index_together | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):
* keywords: => index_together
* stage: Unreviewed => Accepted
* summary: AlterIndexTogether drops overlapping indexes =>
AlterIndexTogether in historical migration drops overlapping indices
* version: 5.2 => 5.1
Comment:
Thanks for the clear report. Bisected to
2abf417c815c20f41c0868d6f66520b32347106e. There was a follow-up to that
removal with respect to fixing a crash in
b44efdfe543c9b9f12690b59777e6b275cb08103, but it looks like we did not go
as far as fixing what you report here: that the correct indexes are not
recreated following a table remake.
It looks like Simon sketched out a possible implementation on the
[
https://forum.djangoproject.com/t/django-5-1-alterindextogether-raising-
typeerror-class-meta-got-invalid-attribute-s-index-together/36450/3 forum]
before a slimmer implementation was chosen to fix the TypeError:
> We can definitely adapt AlterIndexTogether.state_forwards and
.database_(forwards|backwards) to delegate to AddIndex and RemoveIndex by
introspecting state and from_state though.
> Whichever solution we decide to go forward with should serve as a
validation for attempting the same deprecation path on unique_together ->
constraints.
#31834 is almost identical for `unique_together`, but it's possible they
could be (might have to be?) solved separately, since here we're talking
about an operation that can only exist in historical migrations.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36632#comment:1>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.