sql fixes

This commit is contained in:
Christian Grothoff 2021-10-29 19:13:47 +02:00
parent 08b23fb70a
commit 22e7dabef1
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 10 additions and 20 deletions

View File

@ -1,6 +1,6 @@
-- --
-- This file is part of TALER -- This file is part of TALER
-- Copyright (C) 2014--2020 Taler Systems SA -- Copyright (C) 2014--2021 Taler Systems SA
-- --
-- TALER is free software; you can redistribute it and/or modify it under the -- 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 -- terms of the GNU General Public License as published by the Free Software
@ -22,25 +22,20 @@ BEGIN;
-- Unlike the other SQL files, it SHOULD be updated to reflect the -- Unlike the other SQL files, it SHOULD be updated to reflect the
-- latest requirements for dropping tables. -- latest requirements for dropping tables.
-- Drops for exchange-0001.sql
-- Drops for exchange-0003.sql
DROP TABLE IF EXISTS revolving_work_shards CASCADE; DROP TABLE IF EXISTS revolving_work_shards CASCADE;
-- Drops for exchange-0002.sql
DROP TABLE IF EXISTS auditors CASCADE; DROP TABLE IF EXISTS auditors CASCADE;
DROP TABLE IF EXISTS auditor_denom_sigs CASCADE; DROP TABLE IF EXISTS auditor_denom_sigs CASCADE;
DROP TABLE IF EXISTS exchange_sign_keys CASCADE; DROP TABLE IF EXISTS exchange_sign_keys CASCADE;
DROP TABLE IF EXISTS wire_accounts CASCADE; DROP TABLE IF EXISTS wire_accounts CASCADE;
DROP TABLE IF EXISTS signkey_revocations CASCADE; DROP TABLE IF EXISTS signkey_revocations CASCADE;
DROP TABLE IF EXISTS work_shards CASCADE; DROP TABLE IF EXISTS work_shards CASCADE;
-- Drops for 0001.sql
DROP TABLE IF EXISTS prewire CASCADE; DROP TABLE IF EXISTS prewire CASCADE;
DROP TABLE IF EXISTS recoup CASCADE; DROP TABLE IF EXISTS recoup CASCADE;
DROP TABLE IF EXISTS recoup_refresh CASCADE; DROP TABLE IF EXISTS recoup_refresh CASCADE;
DROP TABLE IF EXISTS aggregation_tracking CASCADE; DROP TABLE IF EXISTS aggregation_tracking CASCADE;
DROP TABLE IF EXISTS wire_out CASCADE; DROP TABLE IF EXISTS wire_out CASCADE;
DROP TABLE IF EXISTS wire_targets CASCADE;
DROP TABLE IF EXISTS wire_fee CASCADE; DROP TABLE IF EXISTS wire_fee CASCADE;
DROP TABLE IF EXISTS deposits CASCADE; DROP TABLE IF EXISTS deposits CASCADE;
DROP TABLE IF EXISTS refunds CASCADE; DROP TABLE IF EXISTS refunds CASCADE;
@ -59,11 +54,5 @@ DROP TABLE IF EXISTS denominations CASCADE;
-- Unregister patch (exchange-0001.sql) -- Unregister patch (exchange-0001.sql)
SELECT _v.unregister_patch('exchange-0001'); SELECT _v.unregister_patch('exchange-0001');
-- Unregister patch (exchange-0002.sql)
SELECT _v.unregister_patch('exchange-0002');
-- Unregister patch (exchange-0003.sql)
SELECT _v.unregister_patch('exchange-0003');
-- And we're out of here... -- And we're out of here...
COMMIT; COMMIT;

View File

@ -361,8 +361,9 @@ prepare_statements (struct PostgresClosure *pg)
",kyc_ok" ",kyc_ok"
",wire_target_serial_id AS payment_target_uuid" ",wire_target_serial_id AS payment_target_uuid"
" FROM reserves" " FROM reserves"
" JOIN reserves_in USING (reserve_uuid)" " JOIN reserves_in ri USING (reserve_uuid)"
" JOIN wire_targets USING (wire_target_serial_id)" " JOIN wire_targets wt "
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)"
" WHERE reserve_pub=$1" " WHERE reserve_pub=$1"
" LIMIT 1;", " LIMIT 1;",
1), 1),
@ -375,7 +376,7 @@ prepare_statements (struct PostgresClosure *pg)
/* Used in #postgres_get_kyc_status() */ /* Used in #postgres_get_kyc_status() */
GNUNET_PQ_make_prepare ("get_kyc_status", GNUNET_PQ_make_prepare ("get_kyc_status",
"SELECT" "SELECT"
",kyc_ok" " kyc_ok"
",wire_target_serial_id AS payment_target_uuid" ",wire_target_serial_id AS payment_target_uuid"
" FROM wire_targets" " FROM wire_targets"
" WHERE payto_uri=$1" " WHERE payto_uri=$1"
@ -384,7 +385,7 @@ prepare_statements (struct PostgresClosure *pg)
/* Used in #postgres_select_kyc_status() */ /* Used in #postgres_select_kyc_status() */
GNUNET_PQ_make_prepare ("select_kyc_status", GNUNET_PQ_make_prepare ("select_kyc_status",
"SELECT" "SELECT"
",kyc_ok" " kyc_ok"
",h_payto" ",h_payto"
" FROM wire_targets" " FROM wire_targets"
" WHERE" " WHERE"
@ -400,10 +401,10 @@ prepare_statements (struct PostgresClosure *pg)
") VALUES " ") VALUES "
"($1)" "($1)"
" ON CONFLICT (wire_target_serial_id) DO " " ON CONFLICT (wire_target_serial_id) DO "
" (SELECT " "(SELECT "
" kyc_ok" " kyc_ok"
" ,wire_target_serial_id" " ,wire_target_serial_id"
" )" ")"
" RETURNING " " RETURNING "
" FALSE AS kyc_ok" " FALSE AS kyc_ok"
" wire_target_serial_id;", " wire_target_serial_id;",