Opened 8 years ago

Closed 8 years ago

#26808 closed New feature (fixed)

Support adding class based indexes from Meta class

Reported by: Akshesh Doshi Owned by: Akshesh Doshi
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: db-indexes
Cc: emorley@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Now that class based indexes are for real and can be added via migration files using AddIndex operation, we should allow index addition from Meta class as well.

Users will then be able to create indexes by defining something like the following in their models:

    class Meta:
        indexes = [
            models.Index(fields=['foo', 'bar'], name='my_index_name_idx')

Change History (6)

comment:1 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Markus Holtermann <info@…>, 8 years ago

In f7e00b40:

Refs #26808 -- Avoided clashing keyword arguments in test_autodetector

Factor method signatures in test_autodetector to avoid clashing keyword
arguments when introducing indexes.

comment:3 by Akshesh Doshi, 8 years ago

Has patch: set
Status: newassigned

comment:4 by Ed Morley, 8 years ago

Cc: emorley@… added

comment:5 by Tim Graham, 8 years ago

Triage Stage: AcceptedReady for checkin

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

Resolution: fixed
Status: assignedclosed

In 6a8372e:

Fixed #26808 -- Added Meta.indexes for class-based indexes.

  • Added the index name to its deconstruction.
  • Added indexes to sqlite3.schema._remake_table() so that indexes aren't dropped when _remake_table() is called.

Thanks timgraham & MarkusH for review and advice.

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