summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/operations.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-05-03 01:25:30 -0400
committerSimon Charette <charette.s@gmail.com>2017-05-04 00:02:14 -0400
commitb91868507af08234a30e9a8e7c90b37c561ba315 (patch)
tree332ff103ffcc30c800ffa5df968113b32acd9447 /django/contrib/postgres/operations.py
parentf37467ec7a970e3cb9f9f25c370c4072fc994a6e (diff)
downloaddjango-b91868507af08234a30e9a8e7c90b37c561ba315.tar.gz
Fixed #28161 -- Fixed return type of ArrayField(CITextField()).
Thanks Tim for the review.
Diffstat (limited to 'django/contrib/postgres/operations.py')
-rw-r--r--django/contrib/postgres/operations.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/django/contrib/postgres/operations.py b/django/contrib/postgres/operations.py
index 8ff043b5a9..cb9765928a 100644
--- a/django/contrib/postgres/operations.py
+++ b/django/contrib/postgres/operations.py
@@ -1,4 +1,4 @@
-from django.contrib.postgres.signals import register_hstore_handler
+from django.contrib.postgres.signals import register_type_handlers
from django.db.migrations.operations.base import Operation
@@ -15,6 +15,10 @@ class CreateExtension(Operation):
if schema_editor.connection.vendor != 'postgresql':
return
schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name))
+ # Registering new type handlers cannot be done before the extension is
+ # installed, otherwise a subsequent data migration would use the same
+ # connection.
+ register_type_handlers(schema_editor.connection)
def database_backwards(self, app_label, schema_editor, from_state, to_state):
schema_editor.execute("DROP EXTENSION %s" % schema_editor.quote_name(self.name))
@@ -46,13 +50,6 @@ class HStoreExtension(CreateExtension):
def __init__(self):
self.name = 'hstore'
- def database_forwards(self, app_label, schema_editor, from_state, to_state):
- super().database_forwards(app_label, schema_editor, from_state, to_state)
- # Register hstore straight away as it cannot be done before the
- # extension is installed, a subsequent data migration would use the
- # same connection
- register_hstore_handler(schema_editor.connection)
-
class TrigramExtension(CreateExtension):