diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 6cfc30a..1777843 100644
a
|
b
|
class SchemaTests(TransactionTestCase):
|
1084 | 1084 | self.assertRaises(IntegrityError, UniqueTest.objects.create, year=2012, slug="foo") |
1085 | 1085 | UniqueTest.objects.all().delete() |
1086 | 1086 | |
| 1087 | def test_unique_together_with_fk(self): |
| 1088 | """ |
| 1089 | Tests removing and adding unique_together constraints that include |
| 1090 | a foreign key. |
| 1091 | """ |
| 1092 | # Create the table |
| 1093 | with connection.schema_editor() as editor: |
| 1094 | editor.create_model(Author) |
| 1095 | editor.create_model(Book) |
| 1096 | # Ensure the fields are unique to begin with |
| 1097 | self.assertEqual(Book._meta.unique_together, ()) |
| 1098 | # Add the unique_together constraint |
| 1099 | with connection.schema_editor() as editor: |
| 1100 | editor.alter_unique_together(Book, [], [['author', 'title']]) |
| 1101 | # Alter it back |
| 1102 | with connection.schema_editor() as editor: |
| 1103 | editor.alter_unique_together(Book, [['author', 'title']], []) |
| 1104 | |
1087 | 1105 | def test_index_together(self): |
1088 | 1106 | """ |
1089 | 1107 | Tests removing and adding index_together constraints on a model. |