exchange

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

exchange-0006.sql (1670B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2025 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 --
     16 
     17 BEGIN;
     18 
     19 SELECT _v.register_patch('exchange-0006', NULL, NULL);
     20 
     21 SET search_path TO exchange;
     22 
     23 CREATE PROCEDURE patch_table_kyc_targets()
     24 LANGUAGE plpgsql
     25 AS $$
     26 DECLARE
     27   my_rec RECORD;
     28   my_payto TEXT;
     29   my_is_wallet BOOL;
     30   wtc CURSOR FOR
     31    SELECT
     32      h_normalized_payto
     33     ,payto_uri
     34      FROM exchange.wire_targets;
     35 BEGIN
     36 
     37 -- Only run the migration if the tables already exist.
     38 PERFORM
     39   FROM pg_tables
     40  WHERE schemaname = 'exchange'
     41    AND tablename  = 'kyc_targets';
     42 
     43 IF FOUND
     44 THEN
     45 
     46   FOR my_rec IN wtc
     47   LOOP
     48     my_payto = my_rec.payto_uri;
     49     my_is_wallet
     50       = (LOWER (SUBSTRING (my_payto, 0, 23)) =
     51          'payto://taler-reserve/') OR
     52         (LOWER (SUBSTRING (my_payto, 0, 28)) =
     53          'payto://taler-reserve-http/');
     54     UPDATE kyc_targets
     55       SET is_wallet=my_is_wallet
     56      WHERE h_normalized_payto=my_rec.h_normalized_payto;
     57   END LOOP;
     58 END IF;
     59 
     60 END $$;
     61 
     62 CALL patch_table_kyc_targets();
     63 
     64 DROP PROCEDURE patch_table_kyc_targets;
     65 
     66 COMMIT;