1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.7.x] Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.

Backport of 72729f844e from master
This commit is contained in:
Andrzej Pragacz
2014-11-15 15:43:06 +01:00
committed by Tim Graham
parent 145467a636
commit feded19104
3 changed files with 24 additions and 11 deletions

View File

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