#25412 closed Bug (fixed)
Migrate command does not create index with operator class for CharField
Description ¶
./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)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Bug |
Version: | 1.8 → master |
comment:3 by , 9 years ago
Owner: | changed from | to
---|
comment:4 by , 9 years ago
Has patch: | set |
---|
Pull request here: https://github.com/django/django/pull/5603
comment:6 by , 9 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:7 by , 9 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
comment:8 by , 9 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
All comments have been addressed.
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.