Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28052 closed Bug (fixed)

Django inadvertently removes all indexes when switching to db_index=False

Reported by: Markus Holtermann Owned by: nobody
Component: Migrations Version: 1.11
Severity: Release blocker Keywords:
Cc: Marc Tamlyn Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

  1. Create a model with data = JSONField(db_index=True); makemigrations; migrate
  2. Add a GinIndex(fields=['data'], name='foo') to _meta.indexes; makemigrations; migrate
  3. Remove db_index=True from the JSONField; makemigrations; migrate

After step 2 there will be a Gin index on the data column on the model. After step 3 there's _no_ index on the data column anymore.

Change History (6)

comment:1 by Markus Holtermann, 7 years ago

Has patch: set
Needs documentation: set
Needs tests: set

comment:2 by Markus Holtermann, 7 years ago

Needs documentation: unset
Needs tests: unset

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 663e4894:

Fixed #28052 -- Prevented dropping Meta.indexes when changing db_index to False.

Thanks Marc Tamlyn for the report and Ian Foote/Tim Graham for review.

comment:4 by Tim Graham <timograham@…>, 7 years ago

In 6afede8:

[1.11.x] Fixed #28052 -- Prevented dropping Meta.indexes when changing db_index to False.

Thanks Marc Tamlyn for the report and Ian Foote/Tim Graham for review.

Backport of 663e48947ff8ef3e6a6275bda2d1ee1b0de13be3 from master

comment:5 by Tim Graham <timograham@…>, 7 years ago

In d0e43f2:

Refs #28052 -- Cleaned up some indexes in schema tests.

comment:6 by Tim Graham <timograham@…>, 7 years ago

In 4c12b102:

[1.11.x] Refs #28052 -- Cleaned up some indexes in schema tests.

Backport of d0e43f225f59145903c72c650eeef1f80e12f9ed from master

Note: See TracTickets for help on using tickets.
Back to Top