taler-mailbox-0001.sql (2303B)
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 17 -- @file taler-mailbox-0001.sql 18 -- @brief database schema for taler-mailbox 19 -- @author Christian Grothoff 20 -- @author Martin Schanzenbach 21 22 -- Everything in one big transaction 23 BEGIN; 24 25 -- Check patch versioning is in place. 26 SELECT _v.register_patch('taler-mailbox-0001', NULL, NULL); 27 28 CREATE SCHEMA taler_mailbox; 29 COMMENT ON SCHEMA taler_mailbox IS 'taler-mailbox data'; 30 31 SET search_path TO taler_mailbox; 32 33 ---------------- Entries --------------------------- 34 35 CREATE TABLE IF NOT EXISTS inbox_entries 36 (serial BIGSERIAL PRIMARY KEY 37 ,hashed_signing_key BYTEA 38 ,body BYTEA NOT NULL 39 ); 40 COMMENT ON TABLE inbox_entries 41 IS 'Mailbox entries (messages)'; 42 COMMENT ON COLUMN inbox_entries.hashed_signing_key 43 IS 'The hashed signing key of the mailbox owner'; 44 45 ---------------- Validations --------------------------- 46 47 CREATE TABLE IF NOT EXISTS mailbox_metadata 48 (serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY 49 ,hashed_signing_key BYTEA NOT NULL 50 ,signing_key BYTEA NOT NULL 51 ,signing_key_type BYTEA NOT NULL 52 ,encryption_key BYTEA NOT NULL 53 ,encryption_key_type BYTEA NOT NULL 54 ,expiration INT8 NOT NULL 55 ,info BYTEA NOT NULL 56 ); 57 COMMENT ON TABLE mailbox_metadata 58 IS 'Mailbox configurations / instances'; 59 60 CREATE TABLE IF NOT EXISTS pending_mailbox_registrations 61 (serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY 62 ,created_at INT8 NOT NULL 63 ,hashed_signing_key BYTEA NOT NULL 64 ,order_id BYTEA NOT NULL 65 ,registration_duration INT8 NOT NULL 66 ); 67 COMMENT ON TABLE pending_mailbox_registrations 68 IS 'Pending mailbox registrations'; 69 70 71 -- Complete transaction 72 COMMIT;