Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#25412 closed Bug (fixed)

Migrate command does not create index with operator class for CharField

Reported by: Federico Frenguelli Owned by: Federico Frenguelli
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 Sebastian Brestin, 9 years ago

Owner: changed from nobody to Sebastian Brestin
Status: newassigned

comment:2 by Simon Charette, 9 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 1.8master

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.

comment:3 by Federico Frenguelli, 8 years ago

Owner: changed from Sebastian Brestin to Federico Frenguelli

comment:4 by Federico Frenguelli, 8 years ago

Has patch: set

comment:5 by Simon Charette, 8 years ago

Patch needs improvement: set

Left some comments on the patch.

comment:6 by Simon Charette, 8 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Tim Graham, 8 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:8 by Simon Charette, 8 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

All comments have been addressed.

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

Resolution: fixed
Status: assignedclosed

In 3a36c807:

Fixed #25412 -- Fixed missing PostgreSQL index on Char/TextField when using AlterField.

Thanks to Emanuele Palazzetti for the help.

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

In 722fae4b:

[1.9.x] Fixed #25412 -- Fixed missing PostgreSQL index on Char/TextField when using AlterField.

Thanks to Emanuele Palazzetti for the help.

Backport of 3a36c8079544c83dcdea4e52181efcd2d1e86b9c from master

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

In 905e94a0:

[1.8.x] Fixed #25412 -- Fixed missing PostgreSQL index on Char/TextField when using AlterField.

Thanks to Emanuele Palazzetti for the help.

Backport of 3a36c8079544c83dcdea4e52181efcd2d1e86b9c from master

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