#26889: Index creation different if SlugField in CreateModel or in AddField of a
migration on postgresql
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
aRkadeFR |
Type: Bug | Status: new
Component: | Version: 1.9
Migrations | Keywords: migrations, index, postgresql,
Severity: Normal | slugfield
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
Hello,
I've run into a different index creation behavior of the `django migrate`
command if a `SlugField` of a `Model` is created in the `CreateModel`
method in a migration or in a `AddField` method.
If we have a model like so:
{{{
from django.db import models
class TestModel(models.Model):
""" DocString for the class """
value = models.IntegerField('value of the model')
slug_model = models.SlugField()
}}}
If we leave the slug_models creation in the CreateModel method of the
migration, an index `testt_models_testmodel_slug_model_f9e19be9_like` is
created
{{{
# the index
"testt_models_testmodel_slug_model_f9e19be9_like" btree (slug_model
varchar_pattern_ops)
# the migration
migrations.CreateModel(
name='TestModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('value', models.IntegerField(verbose_name='value of the model')),
('slug_model', models.SlugField()),
],
),
}}}
Now if we create the slug_field with a CreateField method in the
migrations, we don't have the index (that happen if it's actually a
migration after the 0001_initial of an app).
{{{
# migration
migrations.CreateModel(
name='TestModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('value', models.IntegerField(verbose_name='value of the model')),
],
),
migrations.AddField(
model_name='testmodel',
name='slug_model',
field=models.SlugField(),
),
}}}
I would expect either django-migrations to not create index, or have
consistent schema output between the two methods.
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/26889>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.0415a08e8d269d304cd99e7013f5adbf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.