libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

libeufin-nexus-0015.sql (1574B)


      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-nexus-0015', NULL, NULL);
     19 
     20 SET search_path TO libeufin_nexus;
     21 
     22 -- Preserve existing incoming-history IDs and persisted consumer cursors.
     23 -- Allocate subsequent IDs when a transaction becomes eligible for history.
     24 ALTER TABLE talerable_incoming_transactions ADD COLUMN taler_in_id INT8 GENERATED BY DEFAULT AS IDENTITY;
     25 UPDATE talerable_incoming_transactions SET taler_in_id = incoming_transaction_id;
     26 ALTER TABLE talerable_incoming_transactions
     27   ALTER COLUMN taler_in_id SET GENERATED ALWAYS,
     28   ADD PRIMARY KEY (taler_in_id);
     29 COMMENT ON COLUMN talerable_incoming_transactions.taler_in_id IS 'Incoming history publication ID';
     30 
     31 SELECT setval(pg_get_serial_sequence('talerable_incoming_transactions', 'taler_in_id'),
     32               (SELECT COALESCE(MAX(incoming_transaction_id), 0) + 1 FROM incoming_transactions), false);
     33 
     34 COMMIT;