commit f87b0374aa3c89ef11c53b8d61fc317aa728d0af parent 5512e94d100b44c482ea62f72492700e8a1a1df6 Author: Christian Grothoff <christian@grothoff.org> Date: Sun, 21 Dec 2025 20:06:42 +0100 -fix DB migration logic Diffstat:
| M | src/exchangedb/exchange-0006.sql | | | 24 | ++++++++++++++++-------- |
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/exchangedb/exchange-0006.sql b/src/exchangedb/exchange-0006.sql @@ -35,15 +35,23 @@ DECLARE FROM exchange.wire_targets; BEGIN --- Fix any remaining NULL columns in wire_targets -CREATE EXTENSION pgcrypto IF NOT EXISTS pgcrypto; -my_setup_extension = FOUND; -UPDATE wire_targets - SET h_normalized_payto=substring(digest(convert_to(payto_uri, 'UTF8') || E'\\000'::bytea, 'sha512') FROM 1 FOR 32) - WHERE h_normalized_payto IS NULL; -IF my_setup_extension +PERFORM + FROM pg_tables + WHERE schemaname = 'exchange' + AND tablename = 'wire_targets'; +IF FOUND THEN - DROP EXTENSION pgcrypto; + + -- Fix any remaining NULL columns in wire_targets + CREATE EXTENSION IF NOT EXISTS pgcrypto; + my_setup_extension = FOUND; + UPDATE wire_targets + SET h_normalized_payto=substring(digest(convert_to(payto_uri, 'UTF8') || E'\\000'::bytea, 'sha512') FROM 1 FOR 32) + WHERE h_normalized_payto IS NULL; + IF my_setup_extension + THEN + DROP EXTENSION pgcrypto; + END IF; END IF; -- Only run the migration if the tables already exist.