libeufin-bank-0016.sql (1500B)
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 BEGIN; 17 18 SELECT _v.register_patch('libeufin-bank-0016', NULL, NULL); 19 20 SET search_path TO libeufin_bank; 21 22 -- Preserve existing incoming-history IDs and persisted consumer cursors. 23 ALTER TABLE taler_exchange_incoming 24 DROP CONSTRAINT taler_exchange_incoming_exchange_incoming_id_key; 25 UPDATE taler_exchange_incoming SET exchange_incoming_id = bank_transaction; 26 ALTER TABLE taler_exchange_incoming 27 ALTER COLUMN exchange_incoming_id SET GENERATED ALWAYS, 28 ADD PRIMARY KEY (exchange_incoming_id); 29 COMMENT ON COLUMN taler_exchange_incoming.exchange_incoming_id IS 'Incoming history publication ID'; 30 31 SELECT setval(pg_get_serial_sequence('taler_exchange_incoming', 'exchange_incoming_id'), 32 (SELECT COALESCE(MAX(bank_transaction_id), 0) + 1 FROM bank_account_transactions), false); 33 34 COMMIT;