Fixed #27731 -- Implemented CreateModel/AlterFooOperation reduction.

This should alleviate the side effects of disabling the AlterFooOperation
reduction with RemoveField to fix refs #28862 during migration squashing
because CreateModel can perform a reduction with RemoveField.

Thanks Nick Pope for the review.
This commit is contained in:
Simon Charette 2018-07-14 00:32:09 -04:00 committed by Tim Graham
parent ed7898e1b5
commit 8e3f22f251
4 changed files with 95 additions and 20 deletions

View file

@ -2075,8 +2075,10 @@ class AutodetectorTests(TestCase):
changes = self.get_changes([], [self.book, self.author_with_book_order_wrt])
# Right number/type of migrations?
self.assertNumberMigrations(changes, 'testapp', 1)
self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel", "AlterOrderWithRespectTo"])
self.assertOperationAttributes(changes, 'testapp', 0, 1, name="author", order_with_respect_to="book")
self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel"])
self.assertOperationAttributes(
changes, 'testapp', 0, 0, name="Author", options={'order_with_respect_to': 'book'}
)
self.assertNotIn("_order", [name for name, field in changes['testapp'][0].operations[0].fields])
def test_alter_model_managers(self):