aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 1da82f6b..fb639ad8 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -5208,8 +5208,11 @@ CREATE TYPE spo_reason_code AS ENUM ('S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6', '
CREATE TABLE spos (
id int4 NOT NULL GENERATED ALWAYS AS IDENTITY,
dealid text NULL GENERATED ALWAYS AS ('SPO_'::text || id::text) STORED,
+ action action NOT NULL,
fund fund NOT NULL,
cash_account text NOT NULL,
+ trade_date date NOT NULL,
+ settle_date date NOT NULL,
amount numeric(11, 2) NOT NULL,
currency currency NOT NULL,
cp_code varchar(10) NOT NULL REFERENCES counterparties(code) ON UPDATE CASCADE,
@@ -5219,4 +5222,6 @@ CREATE TABLE spos (
reason_code spo_reason_code NOT NULL,
CONSTRAINT spos_cash_account_key UNIQUE (cash_account),
CONSTRAINT spos_pkey PRIMARY KEY (id)
-); \ No newline at end of file
+);
+
+CREATE VIEW spo_trades AS SELECT s.*, a.name AS account_name, c.name AS counterparty_name FROM spos s LEFT JOIN accounts2 a USING (cash_account) LEFT JOIN counterparties c ON c.code=s.cp_code; \ No newline at end of file