aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/0002-batch_deposits.sql
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2023-12-05 12:44:25 +0100
committerChristian Blättler <blatc2@bfh.ch>2023-12-05 12:44:25 +0100
commitf99262923121d5c0e1b995e325d97830110f5ce5 (patch)
tree920eb143e689104eb9d4b9882910ae42296bcce1 /src/exchangedb/0002-batch_deposits.sql
parent9b27ee9c8d7d2bda08c795d9ae60cd2523bd8ffe (diff)
parent4347393e44ca59e305514eeb0d11638c8c38f07d (diff)
downloadexchange-f99262923121d5c0e1b995e325d97830110f5ce5.tar.xz
Merge branch 'master' into feature/tokens
Diffstat (limited to 'src/exchangedb/0002-batch_deposits.sql')
-rw-r--r--src/exchangedb/0002-batch_deposits.sql24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/exchangedb/0002-batch_deposits.sql b/src/exchangedb/0002-batch_deposits.sql
index af0764aa7..71a4b4205 100644
--- a/src/exchangedb/0002-batch_deposits.sql
+++ b/src/exchangedb/0002-batch_deposits.sql
@@ -111,9 +111,6 @@ BEGIN
' PRIMARY KEY (batch_deposit_serial_id) '
',ADD CONSTRAINT ' || table_name || '_merchant_pub_h_contract_terms'
' UNIQUE (shard, merchant_pub, h_contract_terms)'
- ',ADD CONSTRAINT ' || table_name || '_foreign_policy_details'
- ' FOREIGN KEY (policy_details_serial_id) '
- ' REFERENCES policy_details (policy_details_serial_id) ON DELETE RESTRICT'
);
EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_by_ready '
@@ -133,6 +130,22 @@ BEGIN
END
$$;
+CREATE OR REPLACE FUNCTION foreign_table_batch_deposits()
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name TEXT DEFAULT 'batch_deposits';
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_policy_details'
+ ' FOREIGN KEY (policy_details_serial_id) '
+ ' REFERENCES policy_details (policy_details_serial_id) ON DELETE RESTRICT'
+ );
+END
+$$;
+
INSERT INTO exchange_tables
(name
@@ -150,5 +163,10 @@ INSERT INTO exchange_tables
,'exchange-0002'
,'constrain'
,TRUE
+ ,FALSE),
+ ('batch_deposits'
+ ,'exchange-0002'
+ ,'foreign'
+ ,TRUE
,FALSE)
;