diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-07-26 09:21:53 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-07-26 09:22:31 -0700 |
| commit | 7e708a2536d4828d06f7aa4002fbd5cfc20bef16 (patch) | |
| tree | f4360d7e2cee7493816b7947fbeb8ca2d7093171 /django | |
| parent | 3a2badcbb73c2aed6451d2451da1c4fc8d934ab2 (diff) | |
[1.7.x] Fixed #22944: Bad dependency on FK alteration in autodetector
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/autodetector.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index fff5daf08e..7f52b9d07c 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -342,6 +342,13 @@ class MigrationAutodetector(object): isinstance(operation, operations.DeleteModel) and operation.name.lower() == dependency[1].lower() ) + # Field being altered + elif dependency[2] is not None and dependency[3] == "alter": + return ( + isinstance(operation, operations.AlterField) and + operation.model_name.lower() == dependency[1].lower() and + operation.name.lower() == dependency[2].lower() + ) # order_with_respect_to being unset for a field elif dependency[2] is not None and dependency[3] == "order_wrt_unset": return ( @@ -631,7 +638,7 @@ class MigrationAutodetector(object): ) ) # Finally, remove the model. - # This depends on both the removal of all incoming fields + # This depends on both the removal/alteration of all incoming fields # and the removal of all its own related fields, and if it's # a through model the field that references it. dependencies = [] @@ -642,6 +649,12 @@ class MigrationAutodetector(object): related_object.field.name, False, )) + dependencies.append(( + related_object.model._meta.app_label, + related_object.model._meta.object_name, + related_object.field.name, + "alter", + )) for related_object in model._meta.get_all_related_many_to_many_objects(): dependencies.append(( related_object.model._meta.app_label, |
