Opened 8 years ago

Closed 8 years ago

Last modified 3 years ago

#26709 closed New feature (fixed)

Add operation for creating database indexes and class based indexes

Reported by: Akshesh Doshi Owned by: nobody
Component: Migrations Version: dev
Severity: Normal Keywords: db-indexes
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With all the discussion starting from Marc's DEP and continuing at various other places, the first step we can take towards having class based indexes is to create the base Index class and an operation (CreateIndex) to create them. This would allow us to create indexes from the migrations using a defined API of the Index class without even touching the model layer.
A DropIndex will also be required to be created.

Change History (15)

comment:1 by Claude Paroz, 8 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Akshesh Doshi, 8 years ago

Has patch: set
Needs documentation: set

A working model - https://github.com/django/django/pull/6726/

Misses docs for the new Index class.

comment:3 by Akshesh Doshi, 8 years ago

Needs documentation: unset

Added docs for the new index classes.

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

Resolution: fixed
Status: newclosed

In 156e2d59:

Fixed #26709 -- Added class-based indexes.

Added the AddIndex and RemoveIndex operations to use them in migrations.

Thanks markush, mjtamlyn, timgraham, and charettes for review and advice.

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

In b1e7d19d:

Refs #26709 -- Required a name for Indexes passed to AddIndex.

Thanks to Markush for discussions.

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

In f7e9071:

Refs #26709 -- Added IndexOperation to avoid code duplication.

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

In 52442898:

Refs #26709 -- Added 'model' argument to SchemaEditor.add/remove_index()

This removes the dependency of the Index class on its model attribute
when a name is passed to it.

Thanks to Markush for discussions.

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

In 3551fb53:

Refs #26709 -- Documented SchemaEditor.add/remove_index().

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

In fc3ac65:

Refs #26709 -- Checked allow_migrate_model() in Add/RemoveIndex operations.

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

In b92c6b7:

Refs #26709 -- Replaced Index.get_name() with set_name_with_model().

This removes the dependency of the Index class on its 'model'
attribute.

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

In a71724cd:

Refs #26709 -- Added index name to AddIndex.describe().

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

In c969b17:

Refs #26709 -- Added type check for models.Index fields argument.

comment:13 by Markus Holtermann <info@…>, 7 years ago

In e7033e0:

Used constant instead of hard-coded value for max index name length

Refs #26709

comment:14 by Markus Holtermann <info@…>, 7 years ago

In c654ead8:

[1.11.x] Used constant instead of hard-coded value for max index name length

Refs #26709

Backport of e7033e00f8e1ba2ffe538e56c5088a7e94c2e45d from master

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 4c62cdaa:

Refs #26709 -- Made Index raise ValueError on non-string fields.

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