Implement RenameIndex in a backwards compatible way
In order to eventually deprecate index_together
we need a way to deal with old projects that have unnamed indexes. This proves to be a non-trivial problem. Andrew and I came up with these things to consider.
RenameIndex(model, new_name, old_name=None, old_fields=None)
where exactly one of old_name
and old_field
is given (old_name ^ old_fields
)
- If the old_name is given we use
RENAME INDEX
if available
- Otherwise look at the state and drop existing indexes and create new the index with new name
- On MySQL (or other DBs) that don't support
RENAME INDEX
, provide SQL query to look up index name from information_schema by field names and pass in to DROP INDEX
.
- If more than one index is found while identifying with field names, migrations must error out with an
AmbiguityError
- If the autodetector finds an old, unnamed index and a new, named one matching field signature, issue a
RenameIndex
operation
- For backwards operations with unnamed old indexes,
RenameIndex
is a noop.
Type: |
Uncategorized → New feature
|
Cc: |
Andrew Godwin added; anr removed
|
Cc: |
David Wobrock added
|
Has patch: |
set
|
Needs documentation: |
unset
|
Needs tests: |
unset
|
Owner: |
changed from nobody to David Wobrock
|
Status: |
new → assigned
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Needs tests: |
set
|
Patch needs improvement: |
set
|
Needs tests: |
unset
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Patch needs improvement: |
set
|
Triage Stage: |
Ready for checkin → Accepted
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Triage Stage: |
Ready for checkin → Accepted
|
Is there a reason why we cannot just simply deprecate
index_together
.My understanding is that the models file of the app will get modified from this
to this
and everything should work fine (or not? Am I missing something?)
I need some help to see where
RenameIndex
comes into picture here.