summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/operations.py
diff options
context:
space:
mode:
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):