magnet-bank-0003.sql (1371B)
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 SELECT _v.register_patch('magnet-bank-0003', NULL, NULL); 17 18 SET search_path TO magnet_bank; 19 20 -- Preserve existing incoming-history IDs and persisted consumer cursors. 21 -- Allocate subsequent IDs when a transaction becomes eligible for history. 22 ALTER TABLE taler_in ADD COLUMN taler_in_id INT8 GENERATED BY DEFAULT AS IDENTITY; 23 UPDATE taler_in SET taler_in_id = tx_in_id; 24 ALTER TABLE taler_in 25 ALTER COLUMN taler_in_id SET GENERATED ALWAYS, 26 DROP CONSTRAINT taler_in_pkey, 27 ADD UNIQUE (tx_in_id), 28 ADD PRIMARY KEY (taler_in_id); 29 30 SELECT setval(pg_get_serial_sequence('taler_in', 'taler_in_id'), 31 (SELECT COALESCE(MAX(tx_in_id), 0) + 1 FROM tx_in), false);