diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/autodetector.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index 6cd92206ec..f32d4af9eb 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -797,12 +797,19 @@ class MigrationAutodetector: field_dec = self.deep_deconstruct(field) for rem_app_label, rem_model_name, rem_field_name in sorted(self.old_field_keys - self.new_field_keys): if rem_app_label == app_label and rem_model_name == model_name: - old_field_dec = self.deep_deconstruct(old_model_state.get_field_by_name(rem_field_name)) + old_field = old_model_state.get_field_by_name(rem_field_name) + old_field_dec = self.deep_deconstruct(old_field) if field.remote_field and field.remote_field.model and 'to' in old_field_dec[2]: old_rel_to = old_field_dec[2]['to'] if old_rel_to in self.renamed_models_rel: old_field_dec[2]['to'] = self.renamed_models_rel[old_rel_to] - if old_field_dec == field_dec: + old_field.set_attributes_from_name(rem_field_name) + old_db_column = old_field.get_attname_column()[1] + if (old_field_dec == field_dec or ( + # Was the field renamed and db_column equal to the + # old field's column added? + old_field_dec[0:2] == field_dec[0:2] and + dict(old_field_dec[2], db_column=old_db_column) == field_dec[2])): if self.questioner.ask_rename(model_name, rem_field_name, field_name, field): self.add_operation( app_label, |
