Modify ↓
Ticket #731 (closed defect: fixed)
Not picking db_index=False for SlugField
| Reported by: | semenov@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | commands | Version: | unknown |
| Keywords: | Cc: |
Description
South doesn't pick db_index=False for SlugField? when it saves the structure dump along with the migration, which results in endless migrations trying to "fix" that field.
A minimalistic example:
# test/models.py
from django.db import models
class Foo(models.Model):
slug = models.SlugField(db_index=False)
Console output:
$ ./manage.py schemamigration test --initial Creating migrations directory at '/Users/semenov/work/minisites/src/test/migrations'... Creating __init__.py in '/Users/semenov/work/minisites/src/test/migrations'... + Added model test.Foo Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate test $ ./manage.py schemamigration test --auto + Deleted index for ['slug'] on test.Foo Created 0002_auto.py. You can now apply this migration with: ./manage.py migrate test $ ./manage.py schemamigration test --auto + Deleted index for ['slug'] on test.Foo Created 0003_auto.py. You can now apply this migration with: ./manage.py migrate test $ ./manage.py schemamigration test --auto + Deleted index for ['slug'] on test.Foo Created 0004_auto.py. You can now apply this migration with: ./manage.py migrate test
Initial migration file:
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Foo'
db.create_table('test_foo', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('slug', self.gf('django.db.models.fields.SlugField')(max_length=50)), # !!! missing db_index=False
))
db.send_create_signal('test', ['Foo'])
def backwards(self, orm):
# Deleting model 'Foo'
db.delete_table('test_foo')
models = {
'test.foo': {
'Meta': {'object_name': 'Foo'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}) # !!! missing db_index=False
}
}
complete_apps = ['test']
Subsequent (endless) migration files:
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Removing index on 'Foo', fields ['slug']
db.delete_index('test_foo', ['slug'])
def backwards(self, orm):
# Adding index on 'Foo', fields ['slug']
db.create_index('test_foo', ['slug'])
models = {
'test.foo': {
'Meta': {'object_name': 'Foo'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}) # !!! missing db_index=False
}
}
complete_apps = ['test']
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

Fixed in [78e8157f6e56].