commit 1c7401cf6a72a8e6aeac3a569b64c3d00898a1d1
parent 06ffffe57e1487759736761619b864796d86db74
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Tue, 17 Oct 2023 14:14:49 +0200
address TODO: this is a foreign constraint, should be in a foreign helper function
Diffstat:
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/exchangedb/0002-kyc_attributes.sql b/src/exchangedb/0002-kyc_attributes.sql
@@ -108,8 +108,9 @@ BEGIN
'UNIQUE (kyc_attributes_serial_id)'
);
-- The legitimization_serial is a foreign key.
- -- TODO: due to partitioning by h_payto, we can not simply reference
- -- the serial id of the legitimization_processes
+ -- But, due to partitioning by h_payto, we can not simply reference
+ -- the serial id of the legitimization_processes. Thus, the following
+ -- is commented out.
-- EXECUTE FORMAT (
-- 'ALTER TABLE ' || table_name ||
-- ' ADD CONSTRAINT ' || table_name || '_foreign_legitimization_processes'
@@ -131,6 +132,22 @@ BEGIN
END $$;
+CREATE OR REPLACE FUNCTION foreign_table_kyc_attributes()
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name TEXT DEFAULT 'kyc_attributes';
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_legitimization_processes'
+ ' FOREIGN KEY (legitimization_serial) '
+ ' REFERENCES legitimization_processes (legitimization_process_serial_id)' -- ON DELETE CASCADE
+ );
+END $$;
+
+
INSERT INTO exchange_tables
(name
,version
@@ -147,4 +164,9 @@ INSERT INTO exchange_tables
,'exchange-0002'
,'constrain'
,TRUE
+ ,FALSE),
+ ('kyc_attributes'
+ ,'exchange-0002'
+ ,'foreign'
+ ,TRUE
,FALSE);