mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.
This commit is contained in:
parent
f957e2b04c
commit
72729f844e
3 changed files with 24 additions and 11 deletions
|
@ -908,6 +908,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue