Migrate command does not create index with operator class for CharField
./manage.py migrate
command does not create an additional index with the operator class for a CharField, when db_index=True
is added to an existing field.
I created a sample project to reproduce the error here: https://github.com/synasius/foo
There are two models, Person
and Car
.
Person
's "name" field was migrated with db_index=True
and if I run ./manage.py sqlmigrate bar 0001
I can see both the indexes, one using the operator class varchar_pattern_ops
.
The issue occurs when db_index=True
is added to Car
's name field and then a migration is created. When I run ./manage.py sqlmigrate bar 0002
I can only see one plain index.
I reproduced the issue in Django 1.7.x, 1.8.x and master. I'm using postgresql 9.4.4.
Change History
(11)
Owner: |
changed from nobody to Sebastian Brestin
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → Bug
|
Version: |
1.8 → master
|
Owner: |
changed from Sebastian Brestin to Federico Frenguelli
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Patch needs improvement: |
set
|
Triage Stage: |
Ready for checkin → Accepted
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Thanks to the provided sample project I managed to reproduce.
Looks like someone commented on a related ticket to report this inconsistency.
Another oddity is the fact the default non-unique index created has a name ending with
_uniq
which looks quite suspicious.