summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2020-03-07 22:13:58 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-09 12:13:18 +0100
commitec292f261d2390f692d5534ca85a427216bc4e39 (patch)
tree9bd8e5e6637ed19609bb47828e8080453a2d6d2b /django
parentd88365708c554efe3c786c3be6da1d9de916360f (diff)
Fixed #31347 -- Checked allow_migrate() in CreateExtension operation.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/postgres/operations.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/django/contrib/postgres/operations.py b/django/contrib/postgres/operations.py
index 12c850a073..0bb131ddf2 100644
--- a/django/contrib/postgres/operations.py
+++ b/django/contrib/postgres/operations.py
@@ -1,7 +1,7 @@
from django.contrib.postgres.signals import (
get_citext_oids, get_hstore_oids, register_type_handlers,
)
-from django.db import NotSupportedError
+from django.db import NotSupportedError, router
from django.db.migrations import AddIndex, RemoveIndex
from django.db.migrations.operations.base import Operation
@@ -16,7 +16,10 @@ class CreateExtension(Operation):
pass
def database_forwards(self, app_label, schema_editor, from_state, to_state):
- if schema_editor.connection.vendor != 'postgresql':
+ if (
+ schema_editor.connection.vendor != 'postgresql' or
+ not router.allow_migrate(schema_editor.connection.alias, app_label)
+ ):
return
schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name))
# Clear cached, stale oids.
@@ -28,6 +31,8 @@ class CreateExtension(Operation):
register_type_handlers(schema_editor.connection)
def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ if not router.allow_migrate(schema_editor.connection.alias, app_label):
+ return
schema_editor.execute("DROP EXTENSION %s" % schema_editor.quote_name(self.name))
# Clear cached, stale oids.
get_hstore_oids.cache_clear()