diff options
| author | Andrzej Pragacz <apragacz@o2.pl> | 2014-11-15 15:43:06 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-11-21 10:57:38 -0500 |
| commit | feded19104b14bc28aaccf550265157df84593ba (patch) | |
| tree | 21d6a02b76c2dca8b106540165be61075c655176 /tests | |
| parent | 145467a63688eb9055d176d84655cc029060da30 (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 'tests')
| -rw-r--r-- | tests/migrations/test_autodetector.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index 1cf0598c85..9adbf21e4d 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -875,6 +875,22 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, "otherapp", 0, 0, name="book", unique_together=set()) self.assertOperationAttributes(changes, "otherapp", 0, 1, name="book", index_together=set()) + def test_foo_together_remove_fk(self): + """Tests unique_together and field removal detection & ordering""" + # Make state + before = self.make_project_state([self.author_empty, self.book_foo_together]) + after = self.make_project_state([self.author_empty, self.book_with_no_author]) + autodetector = MigrationAutodetector(before, after) + changes = autodetector._detect_changes() + # Right number/type of migrations? + self.assertNumberMigrations(changes, "otherapp", 1) + self.assertOperationTypes(changes, "otherapp", 0, [ + "AlterUniqueTogether", "AlterIndexTogether", "RemoveField" + ]) + self.assertOperationAttributes(changes, "otherapp", 0, 0, name="book", unique_together=set()) + self.assertOperationAttributes(changes, "otherapp", 0, 1, name="book", index_together=set()) + self.assertOperationAttributes(changes, "otherapp", 0, 2, model_name="book", name="author") + def test_foo_together_no_changes(self): """ Tests that index/unique_together doesn't generate a migration if no |
