summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Holtermann <info@markusholtermann.eu>2014-11-17 19:04:38 +0100
committerMarkus Holtermann <info@markusholtermann.eu>2014-11-17 19:15:07 +0100
commit7b4a994599b75a07cb07d1e0cc26b3bbf25ab7a6 (patch)
treee723466b7fc76e7be8a8439cfc2101e73d8cba36 /tests
parent19ae13d9ed76208b29bb40aec1bfff8196aa7331 (diff)
Fixed #23859 -- Fixed a migration crash when a field is renamed that is part of an index_together
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_operations.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 6e7e8d2059..09dc25fd26 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -49,7 +49,7 @@ class OperationTestBase(MigrationTestBase):
def set_up_test_model(self, app_label, second_model=False, third_model=False,
related_model=False, mti_model=False, proxy_model=False,
- unique_together=False, options=False, db_table=None):
+ unique_together=False, options=False, db_table=None, index_together=False):
"""
Creates a test model state and database table.
"""
@@ -81,6 +81,7 @@ class OperationTestBase(MigrationTestBase):
# Make the "current" state
model_options = {
"swappable": "TEST_SWAP_MODEL",
+ "index_together": [["pink", "weight"]] if index_together else [],
"unique_together": [["pink", "weight"]] if unique_together else [],
}
if options:
@@ -984,7 +985,7 @@ class OperationTests(OperationTestBase):
"""
Tests the RenameField operation.
"""
- project_state = self.set_up_test_model("test_rnfl", unique_together=True)
+ project_state = self.set_up_test_model("test_rnfl", unique_together=True, index_together=True)
# Test the state alteration
operation = migrations.RenameField("Pony", "pink", "blue")
self.assertEqual(operation.describe(), "Rename field pink on Pony to blue")
@@ -995,6 +996,9 @@ class OperationTests(OperationTestBase):
# Make sure the unique_together has the renamed column too
self.assertIn("blue", new_state.models["test_rnfl", "pony"].options['unique_together'][0])
self.assertNotIn("pink", new_state.models["test_rnfl", "pony"].options['unique_together'][0])
+ # Make sure the index_together has the renamed column too
+ self.assertIn("blue", new_state.models["test_rnfl", "pony"].options['index_together'][0])
+ self.assertNotIn("pink", new_state.models["test_rnfl", "pony"].options['index_together'][0])
# Test the database alteration
self.assertColumnExists("test_rnfl_pony", "pink")
self.assertColumnNotExists("test_rnfl_pony", "blue")