summaryrefslogtreecommitdiff
path: root/django/db/backends
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends')
-rw-r--r--django/db/backends/postgresql/operations.py2
-rw-r--r--django/db/backends/postgresql/schema.py7
2 files changed, 6 insertions, 3 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
index 268fa99b51..c4a61f7070 100644
--- a/django/db/backends/postgresql/operations.py
+++ b/django/db/backends/postgresql/operations.py
@@ -77,6 +77,8 @@ class DatabaseOperations(BaseDatabaseOperations):
'istartswith', 'endswith', 'iendswith', 'regex', 'iregex'):
if internal_type in ('IPAddressField', 'GenericIPAddressField'):
lookup = "HOST(%s)"
+ elif internal_type in ('CICharField', 'CIEmailField', 'CITextField'):
+ lookup = '%s::citext'
else:
lookup = "%s::text"
diff --git a/django/db/backends/postgresql/schema.py b/django/db/backends/postgresql/schema.py
index 20cea3f249..18388cc523 100644
--- a/django/db/backends/postgresql/schema.py
+++ b/django/db/backends/postgresql/schema.py
@@ -107,11 +107,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def _alter_field(self, model, old_field, new_field, old_type, new_type,
old_db_params, new_db_params, strict=False):
- # Drop indexes on varchar/text columns that are changing to a different
- # type.
+ # Drop indexes on varchar/text/citext columns that are changing to a
+ # different type.
if (old_field.db_index or old_field.unique) and (
(old_type.startswith('varchar') and not new_type.startswith('varchar')) or
- (old_type.startswith('text') and not new_type.startswith('text'))
+ (old_type.startswith('text') and not new_type.startswith('text')) or
+ (old_type.startswith('citext') and not new_type.startswith('citext'))
):
index_name = self._create_index_name(model._meta.db_table, [old_field.column], suffix='_like')
self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))