summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'tests/migrations')
-rw-r--r--tests/migrations/test_base.py2
-rw-r--r--tests/migrations/test_operations.py47
2 files changed, 1 insertions, 48 deletions
diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
index 1f565eb03d..0ff1dda1d9 100644
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -102,7 +102,7 @@ class MigrationTestBase(TransactionTestCase):
.values()
if (
c["columns"] == list(columns)
- and (index_type is None or c.get("type") == index_type)
+ and (index_type is None or c["type"] == index_type)
and not c["unique"]
)
),
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 42629e3494..3ac813b899 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -1,5 +1,4 @@
import math
-import unittest
from decimal import Decimal
from django.core.exceptions import FieldDoesNotExist
@@ -6214,52 +6213,6 @@ class OperationTests(OperationTestBase):
self.assertEqual(pony_new.static, 2)
-class PrimaryKeyOperations(OperationTestBase):
- @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific")
- def test_slugfields_change_primary_key_operations(self):
- operation1 = migrations.CreateModel(
- "SimpleModel",
- [
- ("field1", models.SlugField(max_length=20, primary_key=True)),
- ("field2", models.SlugField(max_length=20)),
- ],
- )
- operation2 = migrations.AlterField(
- "SimpleModel",
- "field1",
- models.SlugField(max_length=20, primary_key=False),
- )
- operation3 = migrations.AlterField(
- "SimpleModel",
- "field2",
- models.SlugField(max_length=20, primary_key=True),
- )
- project_state = ProjectState()
- new_state = project_state.clone()
- operation1.state_forwards("migrtest", new_state)
-
- self.assertTableNotExists("migrtest_simplemodel")
- with connection.schema_editor() as editor:
- operation1.state_forwards("migrtest", new_state)
- operation1.database_forwards("migrtest", editor, project_state, new_state)
- project_state, new_state = new_state, new_state.clone()
- operation2.state_forwards("migrtest", new_state)
- operation2.database_forwards("migrtest", editor, project_state, new_state)
- project_state, new_state = new_state, new_state.clone()
- operation3.state_forwards("migrtest", new_state)
- operation3.database_forwards("migrtest", editor, project_state, new_state)
- self.assertTableExists("migrtest_simplemodel")
- self.assertColumnExists("migrtest_simplemodel", "field1")
- self.assertColumnExists("migrtest_simplemodel", "field2")
- with connection.cursor() as cursor:
- primary_keys = connection.introspection.get_primary_key_columns(
- cursor, "migrtest_simplemodel"
- )
- self.assertEqual(["field2"], primary_keys)
- self.assertIndexExists("migrtest_simplemodel", ["field1"], index_type="idx")
- self.assertIndexExists("migrtest_simplemodel", ["field2"], index_type="idx")
-
-
class SwappableOperationTests(OperationTestBase):
"""
Key operations ignore swappable models