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

Method database_forwards

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

Source from the content-addressed store, hash-verified

109 )
110
111 def database_forwards(self, app_label, schema_editor, from_state, to_state):
112 to_model = to_state.apps.get_model(app_label, self.model_name)
113 if self.allow_migrate_model(schema_editor.connection.alias, to_model):
114 from_model = from_state.apps.get_model(app_label, self.model_name)
115 field = to_model._meta.get_field(self.name)
116 if not self.preserve_default:
117 field.default = self.field.default
118 schema_editor.add_field(
119 from_model,
120 field,
121 )
122 if not self.preserve_default:
123 field.default = NOT_PROVIDED
124
125 def database_backwards(self, app_label, schema_editor, from_state, to_state):
126 from_model = from_state.apps.get_model(app_label, self.model_name)

Calls 4

get_modelMethod · 0.45
allow_migrate_modelMethod · 0.45
get_fieldMethod · 0.45
add_fieldMethod · 0.45