summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrzej Pragacz <apragacz@o2.pl>2014-11-15 15:43:06 +0100
committerTim Graham <timograham@gmail.com>2014-11-21 10:57:38 -0500
commitfeded19104b14bc28aaccf550265157df84593ba (patch)
tree21d6a02b76c2dca8b106540165be61075c655176 /django
parent145467a63688eb9055d176d84655cc029060da30 (diff)
[1.7.x] Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.
Backport of 72729f844e0dd9bd01b3874171b89ab0d136a40e from master
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/autodetector.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index d66817a63c..d5286c7351 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -374,17 +374,11 @@ class MigrationAutodetector(object):
)
# Field is removed and part of an index/unique_together
elif dependency[2] is not None and dependency[3] == "foo_together_change":
- if operation.name.lower() == dependency[1].lower():
- return (
- (
- isinstance(operation, operations.AlterUniqueTogether) and
- any(dependency[2] not in t for t in operation.unique_together)
- ) or
- (
- isinstance(operation, operations.AlterIndexTogether) and
- any(dependency[2] not in t for t in operation.index_together)
- )
- )
+ return (
+ isinstance(operation, (operations.AlterUniqueTogether,
+ operations.AlterIndexTogether)) and
+ operation.name.lower() == dependency[1].lower()
+ )
# Unknown dependency. Raise an error.
else:
raise ValueError("Can't handle dependency %r" % (dependency, ))