mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #11964 -- Added support for database check constraints.
This commit is contained in:
parent
6fbfb5cb96
commit
952f05a6db
29 changed files with 799 additions and 39 deletions
|
@ -67,6 +67,17 @@ class MigrationTestBase(TransactionTestCase):
|
|||
def assertIndexNotExists(self, table, columns):
|
||||
return self.assertIndexExists(table, columns, False)
|
||||
|
||||
def assertConstraintExists(self, table, name, value=True, using='default'):
|
||||
with connections[using].cursor() as cursor:
|
||||
constraints = connections[using].introspection.get_constraints(cursor, table).items()
|
||||
self.assertEqual(
|
||||
value,
|
||||
any(c['check'] for n, c in constraints if n == name),
|
||||
)
|
||||
|
||||
def assertConstraintNotExists(self, table, name):
|
||||
return self.assertConstraintExists(table, name, False)
|
||||
|
||||
def assertFKExists(self, table, columns, to, value=True, using='default'):
|
||||
with connections[using].cursor() as cursor:
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue