MCPcopy
hub / github.com/django/django / database_forwards

Method database_forwards

django/contrib/postgres/operations.py:23–43  ·  view source on GitHub ↗
(self, app_label, schema_editor, from_state, to_state)

Source from the content-addressed store, hash-verified

21 pass
22
23 def database_forwards(self, app_label, schema_editor, from_state, to_state):
24 if schema_editor.connection.vendor != "postgresql" or not router.allow_migrate(
25 schema_editor.connection.alias, app_label, **self.hints
26 ):
27 return
28 if not self.extension_exists(schema_editor, self.name):
29 schema_editor.execute(
30 "CREATE EXTENSION IF NOT EXISTS %s"
31 % schema_editor.quote_name(self.name)
32 )
33 # Clear cached, stale oids.
34 get_hstore_oids.cache_clear()
35 get_citext_oids.cache_clear()
36 # Registering new type handlers cannot be done before the extension is
37 # installed, otherwise a subsequent data migration would use the same
38 # connection.
39 register_type_handlers(schema_editor.connection)
40 if hasattr(schema_editor.connection, "register_geometry_adapters"):
41 schema_editor.connection.register_geometry_adapters(
42 schema_editor.connection.connection, True
43 )
44
45 def database_backwards(self, app_label, schema_editor, from_state, to_state):
46 if schema_editor.connection.vendor != "postgresql" or not router.allow_migrate(

Callers 3

test_no_allow_migrateMethod · 0.95
test_allow_migrateMethod · 0.95

Calls 6

extension_existsMethod · 0.95
register_type_handlersFunction · 0.90
allow_migrateMethod · 0.45
executeMethod · 0.45
quote_nameMethod · 0.45

Tested by 3

test_no_allow_migrateMethod · 0.76
test_allow_migrateMethod · 0.76