diff options
| -rw-r--r-- | sql/dawn.sql | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 1da57f9d..6c9c9d18 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -2,7 +2,8 @@ CREATE TYPE bond_strat AS ENUM('M_STR_MAV', 'M_STR_MEZZ', 'CSO_TRANCH', 'M_CLO_BB20', 'M_CLO_AAA', 'M_CLO_BBB', 'M_MTG_IO', 'M_MTG_THRU', 'M_MTG_GOOD', 'M_MTG_B4PR', 'M_MTG_RW', 'M_MTG_FP', 'M_MTG_LMG', - 'M_MTG_SD', 'M_MTG_PR', 'M_MTG_CRT_SD', 'CRT_LD', 'CRT_LD_JNR'); + 'M_MTG_SD', 'M_MTG_PR', 'M_MTG_CRT_SD', 'CRT_LD', 'CRT_LD_JNR', + 'M_MTG_REPO'); CREATE TYPE cds_strat AS ENUM('HEDGE_CSO', 'HEDGE_CLO', 'HEDGE_MAC', 'HEDGE_MBS', 'SER_IGSNR', 'SER_IGMEZ', 'SER_IGEQY', 'SER_IGINX', 'SER_HYSNR', @@ -149,6 +150,41 @@ CREATE TABLE bonds(id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY, stale bool NOT NULL DEFAULT true, CONSTRAINT bonds_check CHECK (cusip IS NOT NULL OR isin IS NOT NULL)); +CREATE TABLE public.repos ( + id serial NOT NULL, + dealid varchar(28) NULL, + "fund" fund NOT NULL, + lastupdate timestamptz NULL DEFAULT now(), + "action" action NULL, + folder bond_strat NOT NULL, + custodian varchar(12) NOT NULL, + cashaccount varchar(12) NOT NULL, + cp_code varchar(12) NOT NULL, + trade_date date NOT NULL, + settle_date date NOT NULL, + cusip varchar(9) NULL, + isin varchar(12) NULL, + identifier varchar(12) NULL, + description varchar(32) NOT NULL, + transaction_indicator repo_type NULL, + faceamount float8 NOT NULL, + price float8 NOT NULL, + "currency" currency NOT NULL DEFAULT 'USD'::currency, + expiration_date date NULL, + weighted_amount float8 NULL, + haircut float8 NULL, + repo_rate float8 NOT NULL, + "call_notice" call_notice NULL, + daycount day_count NULL, + ticket varchar NULL, + CONSTRAINT repos_pkey PRIMARY KEY (id), + CONSTRAINT repos_cp_code_fkey FOREIGN KEY (cp_code) REFERENCES public.counterparties(code) +); + +CREATE TRIGGER repos AFTER INSERT ON +public.repos FOR EACH ROW EXECUTE FUNCTION auto_dealid(); + + CREATE OR REPLACE FUNCTION notify_id() RETURNS trigger AS $$ |
