Fix altering of indexes alongside uniques

This commit is contained in:
Andrew Godwin 2012-09-24 13:15:08 +01:00
parent 0354cecbfd
commit 49dc1e7d28
1 changed files with 2 additions and 2 deletions

View File

@ -397,7 +397,7 @@ class BaseDatabaseSchemaEditor(object):
}, },
) )
# Removed an index? # Removed an index?
if old_field.db_index and not new_field.db_index and not old_field.unique and not new_field.unique: if old_field.db_index and not new_field.db_index and not old_field.unique and not (not new_field.unique and old_field.unique):
# Find the index for this field # Find the index for this field
index_names = self._constraint_names(model, [old_field.column], index=True) index_names = self._constraint_names(model, [old_field.column], index=True)
if strict and len(index_names) != 1: if strict and len(index_names) != 1:
@ -525,7 +525,7 @@ class BaseDatabaseSchemaEditor(object):
} }
) )
# Added an index? # Added an index?
if not old_field.db_index and new_field.db_index and not old_field.unique and not new_field.unique: if not old_field.db_index and new_field.db_index and not new_field.unique and not (not old_field.unique and new_field.unique):
self.execute( self.execute(
self.sql_create_index % { self.sql_create_index % {
"table": self.quote_name(model._meta.db_table), "table": self.quote_name(model._meta.db_table),