diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-12-13 22:41:20 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-02-19 11:19:01 +0100 |
| commit | 7c18b22e2fa70aa8dcfadb33beb17933abdf7ee4 (patch) | |
| tree | f513fa6078dac88f1f040ae44ecdd2763a60074b /django | |
| parent | ab58f072502e86dfe21b2bd5cccdc5e94dce8d26 (diff) | |
Fixed #32256 -- Fixed migration optimization crash when swapping field names.
This disables optimization of RenameField operation when an old field
name is referenced in subsequent operations.
Co-authored-by: InvalidInterrupt <InvalidInterrupt@users.noreply.github.com>
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/operations/fields.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/migrations/operations/fields.py b/django/db/migrations/operations/fields.py index 8e494fd595..728105ea05 100644 --- a/django/db/migrations/operations/fields.py +++ b/django/db/migrations/operations/fields.py @@ -392,8 +392,11 @@ class RenameField(FieldOperation): ), ] # Skip `FieldOperation.reduce` as we want to run `references_field` - # against self.new_name. + # against self.old_name and self.new_name. return ( super(FieldOperation, self).reduce(operation, app_label) or - not operation.references_field(self.model_name, self.new_name, app_label) + not ( + operation.references_field(self.model_name, self.old_name, app_label) or + operation.references_field(self.model_name, self.new_name, app_label) + ) ) |
