diff options
| author | David Wobrock <david.wobrock@gmail.com> | 2020-04-12 23:59:34 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-23 12:28:51 +0200 |
| commit | 533b208775620b8303b00583aaf011b4e81e6535 (patch) | |
| tree | 6f2837e3f8a0df96d83067f46bea51dde45ea2c9 /tests/migrations/test_base.py | |
| parent | 447980e72ac01da1594dd3373a03ba40b7ee6f80 (diff) | |
Fixed #29224 -- Fixed removing index_together indexes if exists unique_together constraint on the same fields.
Diffstat (limited to 'tests/migrations/test_base.py')
| -rw-r--r-- | tests/migrations/test_base.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py index c4c8b1ee6c..28a57f552d 100644 --- a/tests/migrations/test_base.py +++ b/tests/migrations/test_base.py @@ -62,7 +62,11 @@ class MigrationTestBase(TransactionTestCase): any( c["index"] for c in connections[using].introspection.get_constraints(cursor, table).values() - if c['columns'] == list(columns) and (index_type is None or c['type'] == index_type) + if ( + c['columns'] == list(columns) and + (index_type is None or c['type'] == index_type) and + not c['unique'] + ) ), ) @@ -80,6 +84,14 @@ class MigrationTestBase(TransactionTestCase): def assertConstraintNotExists(self, table, name): return self.assertConstraintExists(table, name, False) + def assertUniqueConstraintExists(self, table, columns, value=True, using='default'): + with connections[using].cursor() as cursor: + constraints = connections[using].introspection.get_constraints(cursor, table).values() + self.assertEqual( + value, + any(c['unique'] for c in constraints if c['columns'] == list(columns)), + ) + def assertFKExists(self, table, columns, to, value=True, using='default'): with connections[using].cursor() as cursor: self.assertEqual( |
