aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/0003-kyc_attributes.sql
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-07-23 12:48:07 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-07-23 12:48:07 +0200
commitd189fccd790a36046e1191d7170f45feb3dfb122 (patch)
treee1bb8b8d25be3e9245eabadb057c496a714947c7 /src/exchangedb/0003-kyc_attributes.sql
parenta56a903da3ec46b4c1d1109cc40c2dc149be956b (diff)
Added reserve_pub to kyc legitimization_processes
Where applicable, the reserve_pub will be passed on to the kcy-legitimization process and persisted along with h_payto. This allows us to set a birthday on the reserve itself, once a related kyc-process has provided one.
Diffstat (limited to 'src/exchangedb/0003-kyc_attributes.sql')
-rw-r--r--src/exchangedb/0003-kyc_attributes.sql16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/exchangedb/0003-kyc_attributes.sql b/src/exchangedb/0003-kyc_attributes.sql
index 18093358..56e274a3 100644
--- a/src/exchangedb/0003-kyc_attributes.sql
+++ b/src/exchangedb/0003-kyc_attributes.sql
@@ -33,6 +33,7 @@ BEGIN
',collection_time INT8 NOT NULL'
',expiration_time INT8 NOT NULL'
',encrypted_attributes BYTEA NOT NULL'
+ ',legitimization_serial INT8 NOT NULL'
') %s ;'
,table_name
,'PARTITION BY HASH (h_payto)'
@@ -85,6 +86,12 @@ BEGIN
,table_name
,partition_suffix
);
+ PERFORM comment_partitioned_column(
+ 'Reference the legitimization process for which theses attributes are gathered for.'
+ ,'legitimization_serial'
+ ,table_name
+ ,partition_suffix
+ );
END $$;
COMMENT ON FUNCTION create_table_kyc_attributes
@@ -106,6 +113,15 @@ BEGIN
' ADD CONSTRAINT ' || table_name || '_serial_key '
'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
+ -- 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
+ -- );
-- To search similar users (e.g. during AML checks)
EXECUTE FORMAT (
'CREATE INDEX ' || table_name || '_similarity_index '