Opened 2 years ago

Closed 2 years ago

Last modified 2 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 Changed 2 years ago by Markus Holtermann

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

comment:2 Changed 2 years ago by Markus Holtermann

Needs documentation: unset
Needs tests: unset

comment:3 Changed 2 years ago by Tim Graham <timograham@…>

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 Changed 2 years ago by Tim Graham <timograham@…>

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 Changed 2 years ago by Tim Graham <timograham@…>

In d0e43f2:

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

comment:6 Changed 2 years ago by Tim Graham <timograham@…>

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