aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-10-31 10:33:49 +0100
committerChristian Grothoff <christian@grothoff.org>2024-11-05 10:37:37 +0100
commit82a0b6522441712c514d836a7e71d37116b0c2f9 (patch)
treeca252c7fc7a3ad3b05767eaaaf192856510de36a
parenta9a63d3f1399ebaad2fee05c7248cd0c8daaf0a6 (diff)
add DB migration
-rw-r--r--src/exchangedb/.gitignore1
-rw-r--r--src/exchangedb/0007-wire_targets.sql72
-rw-r--r--src/exchangedb/Makefile.am10
-rw-r--r--src/exchangedb/exchange-0007.sql.in25
4 files changed, 107 insertions, 1 deletions
diff --git a/src/exchangedb/.gitignore b/src/exchangedb/.gitignore
index 42614b8e6..a0b31eaa4 100644
--- a/src/exchangedb/.gitignore
+++ b/src/exchangedb/.gitignore
@@ -16,3 +16,4 @@ test-exchangedb-populate-select-refunds-by-coin-postgres
exchange-0004.sql
exchange-0005.sql
exchange-0006.sql
+exchange-0007.sql
diff --git a/src/exchangedb/0007-wire_targets.sql b/src/exchangedb/0007-wire_targets.sql
new file mode 100644
index 000000000..e9ee9bd1e
--- /dev/null
+++ b/src/exchangedb/0007-wire_targets.sql
@@ -0,0 +1,72 @@
+--
+-- 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_wire_targets7()
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE wire_targets'
+ ' ADD COLUMN h_normalized_payto BYTEA CHECK(LENGTH(h_normalized_payto)=32)'
+ ' 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
+ );
+END $$;
+
+
+CREATE FUNCTION constrain_table_wire_targets7(
+ IN partition_suffix TEXT
+)
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+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
+$$;
+
+INSERT INTO exchange_tables
+ (name
+ ,version
+ ,action
+ ,partitioned
+ ,by_range)
+ VALUES
+ ('wire_targets7'
+ ,'exchange-0007'
+ ,'alter'
+ ,TRUE
+ ,FALSE),
+ ('wire_targets7'
+ ,'exchange-0007'
+ ,'constrain'
+ ,TRUE
+ ,FALSE);
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 909cd171e..1357f7731 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -26,7 +26,8 @@ sqlinputs = \
exchange-0003.sql.in \
exchange-0004.sql.in \
exchange-0005.sql.in \
- exchange-0006.sql.in
+ exchange-0006.sql.in \
+ exchange-0007.sql.in
sql_DATA = \
benchmark-0001.sql \
@@ -38,6 +39,7 @@ sql_DATA = \
exchange-0004.sql \
exchange-0005.sql \
exchange-0006.sql \
+ exchange-0007.sql \
drop.sql \
procedures.sql
@@ -53,6 +55,7 @@ CLEANFILES = \
exchange-0004.sql \
exchange-0005.sql \
exchange-0006.sql \
+ exchange-0007.sql \
procedures.sql
procedures.sql: procedures.sql.in exchange_do_*.sql
@@ -85,6 +88,11 @@ exchange-0006.sql: exchange-0006.sql.in 0006-*.sql
gcc -E -P -undef - < exchange-0006.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
chmod ugo-w $@
+exchange-0007.sql: exchange-0007.sql.in 0007-*.sql
+ chmod +w $@ 2> /dev/null || true
+ gcc -E -P -undef - < exchange-0007.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
+ chmod ugo-w $@
+
check_SCRIPTS = \
test_idempotency.sh
diff --git a/src/exchangedb/exchange-0007.sql.in b/src/exchangedb/exchange-0007.sql.in
new file mode 100644
index 000000000..c71dc75a4
--- /dev/null
+++ b/src/exchangedb/exchange-0007.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-0007', NULL, NULL);
+SET search_path TO exchange;
+
+#include "0007-wire_targets.sql"
+
+
+COMMIT;