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

Method database_forwards

django/db/migrations/operations/models.py:97–111  ·  view source on GitHub ↗
(self, app_label, schema_editor, from_state, to_state)

Source from the content-addressed store, hash-verified

95 )
96
97 def database_forwards(self, app_label, schema_editor, from_state, to_state):
98 model = to_state.apps.get_model(app_label, self.name)
99 if self.allow_migrate_model(schema_editor.connection.alias, model):
100 schema_editor.create_model(model)
101 # While the `index_together` option has been deprecated some
102 # historical migrations might still have references to them.
103 # This can be moved to the schema editor once it's adapted to
104 # from model states instead of rendered models (#29898).
105 to_model_state = to_state.models[app_label, self.name_lower]
106 if index_together := to_model_state.options.get("index_together"):
107 schema_editor.alter_index_together(
108 model,
109 set(),
110 index_together,
111 )
112
113 def database_backwards(self, app_label, schema_editor, from_state, to_state):
114 model = from_state.apps.get_model(app_label, self.name)

Calls 5

alter_index_togetherMethod · 0.80
get_modelMethod · 0.45
allow_migrate_modelMethod · 0.45
create_modelMethod · 0.45
getMethod · 0.45