libeufin-nexus-0014.sql (2529B)
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-0014', NULL, NULL); 19 20 SET search_path TO libeufin_nexus; 21 -- Drop unused index 22 DROP INDEX talerable_incoming_polymorphism; 23 24 -- Add outgoing transactions metadata field 25 ALTER TABLE transfer_operations ADD COLUMN metadata TEXT; 26 ALTER TABLE talerable_outgoing_transactions ADD COLUMN metadata TEXT; 27 28 -- Replace unused wad type with new mapping type 29 ALTER TYPE taler_incoming_type RENAME VALUE 'wad' TO 'map'; 30 31 ALTER TABLE talerable_incoming_transactions 32 ADD COLUMN authorization_pub BYTEA CHECK (LENGTH(authorization_pub)=32), 33 ADD COLUMN authorization_sig BYTEA CHECK (LENGTH(authorization_sig)=64); 34 35 CREATE TABLE prepared_transfers ( 36 type taler_incoming_type NOT NULL, 37 account_pub BYTEA NOT NULL CHECK (LENGTH(account_pub)=32), 38 authorization_pub BYTEA UNIQUE NOT NULL CHECK (LENGTH(authorization_pub)=32), 39 authorization_sig BYTEA NOT NULL CHECK (LENGTH(authorization_sig)=64), 40 recurrent BOOLEAN NOT NULL, 41 reference_number TEXT UNIQUE NOT NULL CHECK(reference_number ~ '^\d{27}$'), 42 registered_at INT8 NOT NULL, 43 incoming_transaction_id INT8 UNIQUE REFERENCES incoming_transactions(incoming_transaction_id) ON DELETE CASCADE 44 ); 45 CREATE UNIQUE INDEX prepared_transfers_unique_reserve_pub 46 ON prepared_transfers (account_pub) WHERE type = 'reserve'; 47 CREATE INDEX prepared_transfers_timestamp 48 ON prepared_transfers (registered_at); 49 50 CREATE TABLE pending_recurrent_incoming_transactions( 51 incoming_transaction_id INT8 NOT NULL UNIQUE REFERENCES incoming_transactions(incoming_transaction_id) ON DELETE CASCADE, 52 authorization_pub BYTEA NOT NULL REFERENCES prepared_transfers(authorization_pub) 53 ); 54 CREATE INDEX pending_recurrent_incoming_transactions_auth_pub 55 ON pending_recurrent_incoming_transactions (authorization_pub); 56 57 58 COMMIT;