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

Method database_forwards

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

Source from the content-addressed store, hash-verified

233 )
234
235 def database_forwards(self, app_label, schema_editor, from_state, to_state):
236 to_model = to_state.apps.get_model(app_label, self.model_name)
237 if self.allow_migrate_model(schema_editor.connection.alias, to_model):
238 from_model = from_state.apps.get_model(app_label, self.model_name)
239 from_field = from_model._meta.get_field(self.name)
240 to_field = to_model._meta.get_field(self.name)
241 if not self.preserve_default:
242 to_field.default = self.field.default
243 schema_editor.alter_field(from_model, from_field, to_field)
244 if not self.preserve_default:
245 to_field.default = NOT_PROVIDED
246
247 def database_backwards(self, app_label, schema_editor, from_state, to_state):
248 self.database_forwards(app_label, schema_editor, from_state, to_state)

Calls 4

get_modelMethod · 0.45
allow_migrate_modelMethod · 0.45
get_fieldMethod · 0.45
alter_fieldMethod · 0.45