exchange

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

commit fffcb95dd919aeb082e04b3b4abc94aaeb81ee59
parent 8e2fdf7a7984d9085785744b1473a98ee3d69c30
Author: Florian Dold <florian@dold.me>
Date:   Sat, 22 Feb 2025 23:31:18 +0100

migrate aml_history for KYC attributes

Diffstat:
Msrc/exchangedb/.gitignore | 1+
Asrc/exchangedb/0008-aml_history.sql | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/exchangedb/Makefile.am | 10+++++++++-
Asrc/exchangedb/exchange-0008.sql.in | 25+++++++++++++++++++++++++
4 files changed, 115 insertions(+), 1 deletion(-)

diff --git a/src/exchangedb/.gitignore b/src/exchangedb/.gitignore @@ -17,3 +17,4 @@ exchange-0004.sql exchange-0005.sql exchange-0006.sql exchange-0007.sql +exchange-0008.sql diff --git a/src/exchangedb/0008-aml_history.sql b/src/exchangedb/0008-aml_history.sql @@ -0,0 +1,80 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +CREATE FUNCTION alter_table_aml_history8() +RETURNS VOID +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE FORMAT ( + 'ALTER TABLE aml_history' + ' ADD COLUMN kyc_attributes_hash BYTEA CHECK(LENGTH(kyc_attributes_hash)=64)' + ' DEFAULT NULL' + ',ADD COLUMN kyc_attributes_serial_id INT8' + ' DEFAULT NULL' + ';' + ); + + PERFORM comment_partitioned_column( + 'Hash of the new attributes inserted by the AML officer.' + ,'kyc_attributes_hash' + ,'aml_history' + ,NULL + ); + + PERFORM comment_partitioned_column( + 'Attributes inserted by the AML officer.' + ,'kyc_attributes_serial_id' + ,'aml_history' + ,NULL + ); +END $$; + + +-- We need a separate function for this, as we call create_table only once but need to add +-- those constraints to each partition which gets created +CREATE FUNCTION foreign_table_aml_history8() +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'aml_history'; +BEGIN + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' ADD CONSTRAINT ' || table_name || '_foreign_key_kyc_attributes' + ' FOREIGN KEY (kyc_attributes_serial_id)' + ' REFERENCES kyc_attributes (kyc_attributes_serial_id)'); +END +$$; + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('aml_history8' + ,'exchange-0008' + ,'alter' + ,TRUE + ,FALSE), + ('aml_history8' + ,'exchange-0008' + ,'foreign' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am @@ -35,7 +35,8 @@ sqlinputs = \ exchange-0004.sql.in \ exchange-0005.sql.in \ exchange-0006.sql.in \ - exchange-0007.sql.in + exchange-0007.sql.in \ + exchange-0008.sql.in sql_DATA = \ benchmark-0001.sql \ @@ -48,6 +49,7 @@ sql_DATA = \ exchange-0005.sql \ exchange-0006.sql \ exchange-0007.sql \ + exchange-0008.sql \ drop.sql \ procedures.sql @@ -64,6 +66,7 @@ CLEANFILES = \ exchange-0005.sql \ exchange-0006.sql \ exchange-0007.sql \ + exchange-0008.sql \ procedures.sql procedures.sql: procedures.sql.in exchange_do_*.sql @@ -101,6 +104,11 @@ exchange-0007.sql: exchange-0007.sql.in 0007-*.sql gcc -E -P -undef - < exchange-0007.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ chmod ugo-w $@ +exchange-0008.sql: exchange-0008.sql.in 0008-*.sql + chmod +w $@ 2> /dev/null || true + gcc -E -P -undef - < exchange-0008.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ + chmod ugo-w $@ + check_SCRIPTS = \ test_idempotency.sh diff --git a/src/exchangedb/exchange-0008.sql.in b/src/exchangedb/exchange-0008.sql.in @@ -0,0 +1,25 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +BEGIN; + +SELECT _v.register_patch('exchange-0008', NULL, NULL); +SET search_path TO exchange; + +#include "0008-aml_history.sql" + + +COMMIT;