1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #22750, #22248: Model renaming now also alters field FKs

This commit is contained in:
Andrew Godwin
2014-06-07 18:17:31 -07:00
parent 1e84d261d6
commit 4ce7a6bc84
6 changed files with 92 additions and 85 deletions

View File

@@ -46,3 +46,17 @@ class MigrationTestBase(TransactionTestCase):
def assertIndexNotExists(self, table, columns):
return self.assertIndexExists(table, columns, False)
def assertFKExists(self, table, columns, to, value=True):
with connection.cursor() as cursor:
self.assertEqual(
value,
any(
c["foreign_key"] == to
for c in connection.introspection.get_constraints(cursor, table).values()
if c['columns'] == list(columns)
),
)
def assertFKNotExists(self, table, columns, to, value=True):
return self.assertFKExists(table, columns, to, False)