exchange-0001.sql (2446B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2014--2022 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 BEGIN; 18 19 SELECT _v.register_patch('exchange-0001', NULL, NULL); 20 21 CREATE SCHEMA exchange; 22 COMMENT ON SCHEMA exchange IS 'taler-exchange data'; 23 24 SET search_path TO exchange; 25 26 --------------------------------------------------------------------------- 27 -- General procedures for DB setup 28 --------------------------------------------------------------------------- 29 30 CREATE TABLE exchange_tables 31 (table_serial_id INT8 GENERATED BY DEFAULT AS IDENTITY 32 ,name TEXT NOT NULL 33 ,version TEXT NOT NULL 34 ,action TEXT NOT NULL 35 ,partitioned BOOL NOT NULL 36 ,by_range BOOL NOT NULL 37 ,finished BOOL NOT NULL DEFAULT(FALSE)); 38 COMMENT ON TABLE exchange_tables 39 IS 'Tables of the exchange and their status'; 40 COMMENT ON COLUMN exchange_tables.name 41 IS 'Base name of the table (without partition/shard)'; 42 COMMENT ON COLUMN exchange_tables.version 43 IS 'Version of the DB in which the given action happened'; 44 COMMENT ON COLUMN exchange_tables.action 45 IS 'Action to take on the table (e.g. create, alter, constrain, or foreign). Create is done for the master table and each partition; constrain is only for partitions or for master if there are no partitions; master only on master (takes no argument); foreign only on master if there are no partitions.'; 46 COMMENT ON COLUMN exchange_tables.partitioned 47 IS 'TRUE if the table is partitioned'; 48 COMMENT ON COLUMN exchange_tables.by_range 49 IS 'TRUE if the table is partitioned by range'; 50 COMMENT ON COLUMN exchange_tables.finished 51 IS 'TRUE if the respective migration has been run'; 52 53 CREATE INDEX exchange_tables_by_pending 54 ON exchange_tables (table_serial_id) 55 WHERE NOT finished; 56 COMMENT ON INDEX exchange_tables_by_pending 57 IS 'Used by exchange_do_create_tables'; 58 59 60 61 COMMIT;