diff options
author | Tim Graham <timograham@gmail.com> | 2016-01-07 20:06:58 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-01-08 12:47:05 -0500 |
commit | 56aaae58a746eb39d5e92ba60f59f4c750a8e1a8 (patch) | |
tree | 1bf78c509606c35691bbf0ede39b47c484ebf462 /django/db/backends/postgresql/schema.py | |
parent | 54d3ba84066301b9cdbbd657620c0f1e5c2422c0 (diff) | |
download | django-56aaae58a746eb39d5e92ba60f59f4c750a8e1a8.tar.gz |
Fixed #26034 -- Fixed incorrect index handling on PostgreSQL on Char/TextField with unique=True and db_index=True.
Thanks Simon Charette for review.
Diffstat (limited to 'django/db/backends/postgresql/schema.py')
-rw-r--r-- | django/db/backends/postgresql/schema.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/backends/postgresql/schema.py b/django/db/backends/postgresql/schema.py index 42d01f002d..cd9e6cfd5e 100644 --- a/django/db/backends/postgresql/schema.py +++ b/django/db/backends/postgresql/schema.py @@ -111,13 +111,13 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): new_db_params, strict, ) # Added an index? Create any PostgreSQL-specific indexes. - if ((not old_field.db_index and new_field.db_index) or (not old_field.unique and new_field.unique)): + if not old_field.db_index and not old_field.unique and (new_field.db_index or new_field.unique): like_index_statement = self._create_like_index_sql(model, new_field) if like_index_statement is not None: self.execute(like_index_statement) # Removed an index? Drop any PostgreSQL-specific indexes. - if ((not new_field.db_index and old_field.db_index) or (not new_field.unique and old_field.unique)): + if (old_field.db_index or old_field.unique) and not (new_field.db_index or new_field.unique): index_to_remove = self._create_index_name(model, [old_field.column], suffix='_like') index_names = self._constraint_names(model, [old_field.column], index=True) for index_name in index_names: |