summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakki <akki@users.noreply.github.com>2016-09-19 19:47:16 +0530
committerTim Graham <timograham@gmail.com>2016-09-19 10:17:16 -0400
commit358c6f21f8107d830a2f285d49d69bac24a98bdd (patch)
treef57135555710d420b55d6548179d209981e5cfd6
parent9023f25278e60bb2da64cd8fddb243ad2137d400 (diff)
Fixed #27165 -- Removed unnecessary CreateModel(... 'indexes': []) in migrations.
-rw-r--r--django/db/migrations/autodetector.py6
-rw-r--r--tests/migrations/test_autodetector.py6
2 files changed, 4 insertions, 8 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index a0146710e6..b2ee53917f 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -529,10 +529,8 @@ class MigrationAutodetector(object):
related_fields[field.name] = field
if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created:
related_fields[field.name] = field
- # Are there any indexes to defer?
- indexes = model_state.options['indexes']
- model_state.options['indexes'] = []
- # Are there unique/index_together to defer?
+ # Are there indexes/unique|index_together to defer?
+ indexes = model_state.options.pop('indexes')
unique_together = model_state.options.pop('unique_together', None)
index_together = model_state.options.pop('index_together', None)
order_with_respect_to = model_state.options.pop('order_with_respect_to', None)
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index e1469760ee..b5d9da07d3 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -1344,7 +1344,7 @@ class AutodetectorTests(TestCase):
self.assertNumberMigrations(changes, "testapp", 1)
self.assertOperationTypes(changes, "testapp", 0, ["DeleteModel", "CreateModel"])
self.assertOperationAttributes(changes, "testapp", 0, 0, name="AuthorProxy")
- self.assertOperationAttributes(changes, "testapp", 0, 1, name="AuthorProxy", options={"indexes": []})
+ self.assertOperationAttributes(changes, "testapp", 0, 1, name="AuthorProxy", options={})
def test_proxy_custom_pk(self):
"""
@@ -1434,9 +1434,7 @@ class AutodetectorTests(TestCase):
# Right number/type of migrations?
self.assertNumberMigrations(changes, 'testapp', 1)
self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel"])
- self.assertOperationAttributes(
- changes, 'testapp', 0, 0, name="AuthorUnmanaged", options={"managed": False, "indexes": []}
- )
+ self.assertOperationAttributes(changes, 'testapp', 0, 0, name="AuthorUnmanaged", options={"managed": False})
def test_unmanaged_to_managed(self):
# Now, we test turning an unmanaged model into a managed model