aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index d0db7ba3..9f9d3440 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -421,6 +421,18 @@ CREATE TABLE swaptions(id serial PRIMARY KEY,
CREATE TRIGGER swaptions_dealid AFTER INSERT ON swaptions
FOR EACH ROW EXECUTE PROCEDURE auto_dealid();
+CREATE TABLE account_counterparty (
+ account_id int4 NULL,
+ cp_code varchar(12) NULL,
+ "trade_type" text NOT NULL,
+ id int4 NOT NULL GENERATED ALWAYS AS IDENTITY,
+ "name" text NULL,
+ CONSTRAINT account_counterparty_account_id_cp_code_trade_type_key UNIQUE (account_id, cp_code, trade_type),
+ CONSTRAINT account_counterparty_pkey PRIMARY KEY (id),
+ CONSTRAINT account_counterparty_account_id_fkey FOREIGN KEY (account_id) REFERENCES accounts2(id),
+ CONSTRAINT account_counterparty_cp_code_fkey FOREIGN KEY (cp_code) REFERENCES counterparties(code) ON UPDATE CASCADE
+);
+
CREATE OR REPLACE FUNCTION update_account(p_trade_type)
RETURNS TRIGGER