taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

magnet-bank-0002.sql (2153B)


      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-0002', NULL, NULL);
     17 
     18 SET search_path TO magnet_bank;
     19 
     20 -- Add outgoing transactions metadata field
     21 ALTER TABLE taler_out ADD COLUMN metadata TEXT;
     22 ALTER TABLE transfer ADD COLUMN metadata TEXT;
     23 
     24 -- Replace unused wad type with new mapping type
     25 ALTER TYPE incoming_type RENAME VALUE 'wad' TO 'map';
     26 
     27 ALTER TABLE taler_in
     28   ADD COLUMN authorization_pub BYTEA CHECK (LENGTH(authorization_pub)=32),
     29   ADD COLUMN authorization_sig BYTEA CHECK (LENGTH(authorization_sig)=64);
     30 
     31 CREATE TABLE prepared_in (
     32   type incoming_type NOT NULL,
     33   account_pub BYTEA NOT NULL CHECK (LENGTH(account_pub)=32),
     34   authorization_pub BYTEA UNIQUE NOT NULL CHECK (LENGTH(authorization_pub)=32),
     35   authorization_sig BYTEA NOT NULL CHECK (LENGTH(authorization_sig)=64),
     36   recurrent BOOLEAN NOT NULL,
     37   registered_at INT8 NOT NULL,
     38   tx_in_id INT8 UNIQUE REFERENCES tx_in(tx_in_id) ON DELETE CASCADE
     39 );
     40 COMMENT ON TABLE prepared_in IS 'Prepared incoming transaction';
     41 CREATE UNIQUE INDEX prepared_in_unique_reserve_pub 
     42   ON prepared_in (account_pub) WHERE type = 'reserve';
     43 
     44 CREATE TABLE pending_recurrent_in(
     45   tx_in_id INT8 NOT NULL UNIQUE REFERENCES tx_in(tx_in_id) ON DELETE CASCADE,
     46   authorization_pub BYTEA NOT NULL REFERENCES prepared_in(authorization_pub)
     47 );
     48 CREATE INDEX pending_recurrent_inc_auth_pub
     49   ON pending_recurrent_in (authorization_pub);
     50 COMMENT ON TABLE pending_recurrent_in IS 'Pending recurrent incoming transaction';