exchange-0016.sql (2233B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2026 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 18 BEGIN; 19 20 SELECT _v.register_patch('exchange-0016', NULL, NULL); 21 22 SET search_path TO exchange; 23 24 25 -- Record the position of a recouped coin in the batch of coins that the 26 -- exchange signed in the original withdraw or refresh operation. The batch 27 -- recoup protocol (see #9828) identifies coins by that position, and the 28 -- coin history reports it so that a wallet can replay the recoup. 29 -- 30 -- The recoup endpoints were disabled before this column was introduced, so 31 -- no rows are expected to predate it; the default only keeps the migration 32 -- from failing on a database that has some. 33 34 CREATE FUNCTION alter_table_recoup16() 35 RETURNS void 36 LANGUAGE plpgsql 37 AS $$ 38 BEGIN 39 ALTER TABLE recoup 40 ADD COLUMN coin_index INT4 NOT NULL DEFAULT (0); 41 COMMENT ON COLUMN recoup.coin_index 42 IS 'index of the coin in the batch of coins signed in the withdraw operation referenced by withdraw_id, starting at 0'; 43 END 44 $$; 45 46 CREATE FUNCTION alter_table_recoup_refresh16() 47 RETURNS void 48 LANGUAGE plpgsql 49 AS $$ 50 BEGIN 51 ALTER TABLE recoup_refresh 52 ADD COLUMN coin_index INT4 NOT NULL DEFAULT (0); 53 COMMENT ON COLUMN recoup_refresh.coin_index 54 IS 'index of the coin in the batch of coins signed in the refresh operation referenced by refresh_id, starting at 0'; 55 END 56 $$; 57 58 INSERT INTO exchange_tables 59 (name 60 ,version 61 ,action 62 ,partitioned 63 ,by_range) 64 VALUES 65 ('recoup16' 66 ,'exchange-0016' 67 ,'alter' 68 ,TRUE 69 ,FALSE), 70 ('recoup_refresh16' 71 ,'exchange-0016' 72 ,'alter' 73 ,TRUE 74 ,FALSE); 75 76 COMMIT;