| 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) |