[Django] #25412: Migrate command does not create index with operator class for CharField

34 views
Skip to first unread message

Django

unread,
Sep 16, 2015, 4:05:31 AM9/16/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
-------------------------------+--------------------
Reporter: synasius | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
`./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.

--
Ticket URL: <https://code.djangoproject.com/ticket/25412>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 16, 2015, 3:13:45 PM9/16/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
-------------------------------+--------------------------------------
Reporter: synasius | Owner: bsebi
Type: Uncategorized | Status: assigned
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by bsebi):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => bsebi
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:1>

Django

unread,
Sep 16, 2015, 5:32:21 PM9/16/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+------------------------------------
Reporter: synasius | Owner: bsebi
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by charettes):

* version: 1.8 => master
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Thanks to the provided sample project I managed to reproduce.

Looks like someone [https://code.djangoproject.com/ticket/24088#comment:5
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:2>

Django

unread,
Nov 7, 2015, 6:41:52 AM11/7/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+------------------------------------
Reporter: synasius | Owner: synasius

Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by synasius):

* owner: bsebi => synasius


--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:3>

Django

unread,
Nov 7, 2015, 11:32:37 AM11/7/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+------------------------------------
Reporter: synasius | Owner: synasius
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by synasius):

* has_patch: 0 => 1


Comment:

Pull request here: https://github.com/django/django/pull/5603

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:4>

Django

unread,
Nov 7, 2015, 2:01:37 PM11/7/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+------------------------------------
Reporter: synasius | Owner: synasius
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by charettes):

* needs_better_patch: 0 => 1


Comment:

Left some comments on the patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:5>

Django

unread,
Nov 23, 2015, 11:36:12 AM11/23/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+---------------------------------------------

Reporter: synasius | Owner: synasius
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:6>

Django

unread,
Nov 23, 2015, 6:21:30 PM11/23/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+------------------------------------

Reporter: synasius | Owner: synasius
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1

* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:7>

Django

unread,
Nov 25, 2015, 11:40:58 AM11/25/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+---------------------------------------------

Reporter: synasius | Owner: synasius
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

All comments have been addressed.

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:8>

Django

unread,
Dec 10, 2015, 4:19:49 PM12/10/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+---------------------------------------------
Reporter: synasius | Owner: synasius
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3a36c8079544c83dcdea4e52181efcd2d1e86b9c" 3a36c807]:
{{{
#!CommitTicketReference repository=""
revision="3a36c8079544c83dcdea4e52181efcd2d1e86b9c"
Fixed #25412 -- Fixed missing PostgreSQL index on Char/TextField when
using AlterField.

Thanks to Emanuele Palazzetti for the help.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:9>

Django

unread,
Dec 10, 2015, 4:33:22 PM12/10/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+---------------------------------------------
Reporter: synasius | Owner: synasius
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"722fae4b5159b2810e252e3385936f86f04eb09b" 722fae4b]:
{{{
#!CommitTicketReference repository=""
revision="722fae4b5159b2810e252e3385936f86f04eb09b"
[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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:10>

Django

unread,
Dec 10, 2015, 4:33:29 PM12/10/15
to django-...@googlegroups.com
#25412: Migrate command does not create index with operator class for CharField
----------------------------+---------------------------------------------
Reporter: synasius | Owner: synasius
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"905e94a07e557f470fd1d01e7cd067cdae2b7794" 905e94a0]:
{{{
#!CommitTicketReference repository=""
revision="905e94a07e557f470fd1d01e7cd067cdae2b7794"
[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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25412#comment:11>

Reply all
Reply to author
Forward
0 new messages