merchant-0008.sql (2117B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2024 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 17 -- @file merchant-0008.sql 18 -- @brief add merchant_issued_tokens table 19 -- @author Christian Blättler 20 21 -- Everything in one big transaction 22 BEGIN; 23 24 -- Check patch versioning is in place. 25 SELECT _v.register_patch('merchant-0008', NULL, NULL); 26 27 SET search_path TO merchant; 28 29 30 CREATE TABLE IF NOT EXISTS merchant_issued_tokens 31 (issued_token_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY 32 ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) 33 ,token_family_key_serial BIGINT REFERENCES merchant_token_family_keys(token_family_key_serial) ON DELETE CASCADE 34 ,blind_sig BYTEA NOT NULL 35 ); 36 COMMENT ON TABLE merchant_issued_tokens 37 IS 'Tokens that have been (blindly) issued to customers.'; 38 COMMENT ON COLUMN merchant_issued_tokens.h_contract_terms 39 IS 'This is no foreign key by design.'; 40 COMMENT ON COLUMN merchant_issued_tokens.token_family_key_serial 41 IS 'Token family key to which the spent token belongs.'; 42 COMMENT ON COLUMN merchant_issued_tokens.blind_sig 43 IS 'Blind signature made with token issue key to prove validity of token.'; 44 45 ALTER TABLE merchant_spent_tokens RENAME TO merchant_used_tokens; 46 47 ALTER TABLE merchant_token_families 48 ADD COLUMN rounding BIGINT NOT NULL; 49 50 ALTER TABLE merchant_token_families 51 RENAME COLUMN redeemed TO used; 52 53 COMMENT ON COLUMN merchant_token_families.rounding 54 IS 'Token start date rounding granularity.'; 55 56 57 -- Complete transaction 58 COMMIT;