exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit e25837126597f1a95c5c38294546ebc282167857
parent 511173a4bf138a14948e21c5b1f4938741c2e45e
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Wed,  7 May 2025 17:10:07 +0200

merge 7-wire_targets

Diffstat:
Msrc/exchangedb/0002-wire_targets.sql | 21++++++++++++++++++++-
Msrc/exchangedb/0007-wire_targets.sql | 25++-----------------------
Msrc/exchangedb/exchange-0007.sql.in | 1-
3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/src/exchangedb/0002-wire_targets.sql b/src/exchangedb/0002-wire_targets.sql @@ -40,7 +40,9 @@ BEGIN ',payto_uri TEXT NOT NULL' ',access_token BYTEA CHECK(LENGTH(access_token)=32)' ' DEFAULT random_bytea(32)' - ',ADD COLUMN target_pub BYTEA CHECK(LENGTH(target_pub)=32) DEFAULT NULL' + ',target_pub BYTEA CHECK(LENGTH(target_pub)=32) DEFAULT NULL' + ',h_normalized_payto BYTEA CHECK(LENGTH(h_normalized_payto)=32) DEFAULT NULL' + ',aml_program_lock_timeout INT8 DEFAULT NULL' ') %s ;' ,'wire_targets' ,'PARTITION BY HASH (wire_target_h_payto)' @@ -75,6 +77,18 @@ BEGIN ,'wire_targets' ,NULL ); + PERFORM comment_partitioned_column( + 'hash over the normalized payto URI for this account; used for KYC operations; NULL if not available (due to DB migration not initializing this value)' + ,'h_normalized_payto' + ,'wire_targets' + ,NULL + ); + PERFORM comment_partitioned_column( + 'If non-NULL, an AML program should be running and it holds a lock on this account, thus other AML programs should not be started concurrently. Given the possibility of crashes, the lock automatically expires at the time value given in this column. At that time, the lock can be considered stale.' + ,'aml_program_lock_timeout' + ,'wire_targets' + ,NULL + ); END $$; @@ -98,6 +112,11 @@ BEGIN ' ADD CONSTRAINT ' || table_name || '_wire_target_access_token_unique' ' UNIQUE (access_token)' ); + EXECUTE FORMAT ( + 'CREATE INDEX ' || table_name || '_normalized_h_payto_index ' + 'ON ' || table_name || ' ' + '(h_normalized_payto);' + ); END $$; diff --git a/src/exchangedb/0007-wire_targets.sql b/src/exchangedb/0007-wire_targets.sql @@ -21,26 +21,10 @@ AS $$ BEGIN EXECUTE FORMAT ( 'ALTER TABLE wire_targets' - ' ADD COLUMN h_normalized_payto BYTEA CHECK(LENGTH(h_normalized_payto)=32)' - ' DEFAULT NULL' - ',ADD COLUMN aml_program_lock_timeout INT8' - ' DEFAULT NULL' - ';' - ); - PERFORM comment_partitioned_column( - 'hash over the normalized payto URI for this account; used for KYC operations; NULL if not available (due to DB migration not initializing this value)' - ,'h_normalized_payto' - ,'wire_targets' - ,NULL - ); - PERFORM comment_partitioned_column( - 'If non-NULL, an AML program should be running and it holds a lock on this account, thus other AML programs should not be started concurrently. Given the possibility of crashes, the lock automatically expires at the time value given in this column. At that time, the lock can be considered stale.' - ,'aml_program_lock_timeout' - ,'wire_targets' - ,NULL ); -END $$; + + CREATE FUNCTION constrain_table_wire_targets7( @@ -53,11 +37,6 @@ DECLARE table_name TEXT DEFAULT 'wire_targets'; BEGIN table_name = concat_ws('_', table_name, partition_suffix); - EXECUTE FORMAT ( - 'CREATE INDEX ' || table_name || '_normalized_h_payto_index ' - 'ON ' || table_name || ' ' - '(h_normalized_payto);' - ); END $$; diff --git a/src/exchangedb/exchange-0007.sql.in b/src/exchangedb/exchange-0007.sql.in @@ -19,7 +19,6 @@ BEGIN; SELECT _v.register_patch('exchange-0007', NULL, NULL); SET search_path TO exchange; -#include "0007-wire_targets.sql" #include "0007-legitimization_outcomes.sql" #include "0007-batch_deposits.sql" #include "0007-kyc_attributes.sql"