aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql23
1 files changed, 10 insertions, 13 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index fc4e695f..ae3fb3fe 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -3193,16 +3193,14 @@ CREATE TABLE citco_tranche (
CONSTRAINT citco_tranche_un UNIQUE (underlying_security_id, attach, detach)
);
-
+CREATE FUNCTION instrument_cast(inst instrument_type) RETURNS text
+LANGUAGE SQL
+IMMUTABLE
+RETURN instrument_type::text;
CREATE TABLE citco_swaption (
- id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- dealid varchar(28) NULL GENERATED ALWAYS AS ((((
- CASE
- WHEN instrument_type = 'SWPO'::instrument_type THEN 'SWPO'::text
- WHEN instrument_type = 'BNDO'::instrument_type THEN 'BNDO'::text
- ELSE NULL::text
- END) || id::text))) STORED,
+ id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
+ dealid varchar(28) NULL GENERATED ALWAYS AS (instrument_cast(instrument_type) || '_' || id::text) STORED,
instrument_type instrument_type NOT NULL,
underlying_id_source id_source NOT NULL,
underlying_security_id text NOT NULL,
@@ -3212,9 +3210,8 @@ CREATE TABLE citco_swaption (
strike float8 NOT NULL,
expiration date NOT NULL,
callput bool NULL,
- commited bool NOT NULL DEFAULT false,
- CONSTRAINT citco_swaption_pkey PRIMARY KEY (id),
- CONSTRAINT citco_swaption_un UNIQUE (instrument_type, underlying_security_id, strike, expiration, callput)
+ committed bool NOT NULL DEFAULT false,
+ UNIQUE (instrument_type, underlying_security_id, strike, expiration, callput)
);
CREATE TABLE citco_irs (
@@ -3238,7 +3235,7 @@ CREATE TABLE citco_irs (
"currency" "currency" NOT NULL,
float_fixing_freq "frequency" NOT NULL,
pay_interest_calc_method "interest_calc_method" NOT NULL,
- commited bool NOT NULL default False,
+ committed bool NOT NULL default False,
);
@@ -3267,7 +3264,7 @@ CREATE TABLE citco_trs (
"interest_calc_method" "interest_calc_method" NOT NULL,
compound_avg_frequency "frequency" NOT NULL,
fixing_frequency "frequency" NOT NULL,
- commited bool NOT NULL default False
+ committed bool NOT NULL default False
);