summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-08-01 09:21:07 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-08-01 09:25:33 +0200
commit3dac3271d286f2790780e89d31ddbb7197f8defa (patch)
tree79c692137c241e587c82dea21e3d76b2afe320d6 /tests/migrations
parent8cf931dd2fde2561a615b96d5f709c15b672c4ba (diff)
Reverted "Fixed #28646 -- Prevented duplicate index when unique is set to True on PostgreSQL."
This reverts commit 9cf9c796be8dd53bc3b11355ff39d65c81d7be6d due to a crash on Oracle as it didn't allow multiple indexes on the same field.
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