aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn')
-rw-r--r--python/Dawn/models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/Dawn/models.py b/python/Dawn/models.py
index 70a3cce7..5ddf0d31 100644
--- a/python/Dawn/models.py
+++ b/python/Dawn/models.py
@@ -189,9 +189,13 @@ class CDSDeal(db.Model):
counterparty = db.relationship(Counterparties, foreign_keys=[cp_code])
termination_counterparty = db.relationship(Counterparties, foreign_keys=[termination_cp])
fcm_account = db.relationship(Accounts, foreign_keys=[account_code])
- __table_args__ = (db.CheckConstraint("swap_type!='CD_INDEX_TRANCHE' or " \
- "(orig_attach is not NULL and orig_detach is not NULL AND " \
- "clearing_facility is NULL)"),)
+ __table_args__ = (db.CheckConstraint(
+ "(swap_type IN ('CD_INDEX_TRANCHE', 'BESPOKE') AND "
+ "(orig_attach IS NOT NULL AND orig_detach IS NOT NULL AND clearing_facility IS NULL))"
+ "OR (swap_type='CD_INDEX' AND "
+ "orig_attach IS NULL AND orig_detach IS NULL AND clearing_facility='ICE-CREDIT')"
+ "OR (swap_type='ABS_CDS' AND "
+ "orig_attach IS NULL AND orig_detach IS NULL AND clearing_faciliy IS NULL)"),)
class RepoDeal(db.Model):
__tablename__ = 'repo'