Skip to content

Commit

Permalink
Fix altering of indexes alongside uniques
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Sep 24, 2012
1 parent 0354cec commit 49dc1e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django/db/backends/schema.py
Expand Up @@ -397,7 +397,7 @@ def alter_field(self, model, old_field, new_field, strict=False):
},
)
# 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
index_names = self._constraint_names(model, [old_field.column], index=True)
if strict and len(index_names) != 1:
Expand Down Expand Up @@ -525,7 +525,7 @@ def alter_field(self, model, old_field, new_field, strict=False):
}
)
# 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.sql_create_index % {
"table": self.quote_name(model._meta.db_table),
Expand Down

0 comments on commit 49dc1e7

Please sign in to comment.