diff options
-rw-r--r-- | src/exchangedb/0004-refunds.sql | 35 | ||||
-rw-r--r-- | src/exchangedb/Makefile.am | 10 | ||||
-rw-r--r-- | src/exchangedb/exchange-0004.sql.in | 24 |
3 files changed, 68 insertions, 1 deletions
diff --git a/src/exchangedb/0004-refunds.sql b/src/exchangedb/0004-refunds.sql new file mode 100644 index 000000000..71666d9db --- /dev/null +++ b/src/exchangedb/0004-refunds.sql @@ -0,0 +1,35 @@ + +CREATE FUNCTION constrain_table_refunds4 ( + IN partition_suffix TEXT DEFAULT NULL +) +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'refunds'; +BEGIN + table_name = concat_ws('_', table_name, partition_suffix); + + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' DROP CONSTRAINT refunds_pkey' + ); + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' ADD PRIMARY KEY (batch_deposit_serial_id, coin_pub, rtransaction_id) ' + ); +END +$$; + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('refunds4' + ,'exchange-0004' + ,'constrain' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 45070ac08..d57d690a1 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -19,8 +19,10 @@ sqlinputs = \ procedures.sql.in \ 0002-*.sql \ 0003-*.sql \ + 0004-*.sql \ exchange-0002.sql.in \ - exchange-0003.sql.in + exchange-0003.sql.in \ + exchange-0004.sql.in sql_DATA = \ benchmark-0001.sql \ @@ -29,6 +31,7 @@ sql_DATA = \ exchange-0001.sql \ exchange-0002.sql \ exchange-0003.sql \ + exchange-0004.sql \ drop.sql \ procedures.sql @@ -58,6 +61,11 @@ exchange-0003.sql: exchange-0003.sql.in 0003-*.sql gcc -E -P -undef - < exchange-0003.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ chmod ugo-w $@ +exchange-0004.sql: exchange-0004.sql.in 0004-*.sql + chmod +w $@ || true + gcc -E -P -undef - < exchange-0004.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@ + chmod ugo-w $@ + check_SCRIPTS = \ test_idempotency.sh diff --git a/src/exchangedb/exchange-0004.sql.in b/src/exchangedb/exchange-0004.sql.in new file mode 100644 index 000000000..c966aedc5 --- /dev/null +++ b/src/exchangedb/exchange-0004.sql.in @@ -0,0 +1,24 @@ +-- +-- 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-0004', NULL, NULL); +SET search_path TO exchange; + +#include "0004-refunds.sql" + +COMMIT; |