challenger-0005.sql (2159B)
1 -- 2 -- This file is part of Challenger 3 -- Copyright (C) 2026 Taler Systems SA 4 -- 5 -- Challenger 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 -- Challenger 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 -- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 -- 16 17 -- Everything in one big transaction 18 BEGIN; 19 20 -- Check patch versioning is in place. 21 SELECT _v.register_patch('challenger-0005', NULL, NULL); 22 23 SET search_path TO challenger; 24 25 -- A PIN that was generated for transmission but whose delivery has not 26 -- been confirmed yet. It only becomes 'last_pin' once the AUTH_COMMAND 27 -- helper exited successfully, so that a failed transmission does not 28 -- invalidate the PIN the user may already hold. 29 ALTER TABLE validations 30 ADD COLUMN pending_pin INT4 DEFAULT NULL; 31 COMMENT ON COLUMN validations.pending_pin 32 IS 'PIN that was passed to the AUTH_COMMAND helper but whose transmission was not confirmed yet; promoted to last_pin when the helper terminates successfully'; 33 34 -- challenger-0004 made validation_serial_id the primary key, but (unlike for 35 -- 'clients', where it dropped clients_client_serial_id_key) it left the 36 -- now redundant UNIQUE constraint from challenger-0001 in place. 37 ALTER TABLE validations 38 DROP CONSTRAINT IF EXISTS validations_validation_serial_id_key; 39 40 -- Fix missing 'GENERATED ALWAYS' and UNIQUE constraints on the 41 -- grant_serial_id 42 ALTER TABLE tokens 43 ADD CONSTRAINT tokens_grant_serial_id_key UNIQUE (grant_serial_id), 44 ALTER COLUMN grant_serial_id SET GENERATED ALWAYS; 45 COMMENT ON COLUMN tokens.grant_serial_id 46 IS 'Unique ID of the grant; published by /info as the resource identifier, hence GENERATED ALWAYS: it must not be settable by an INSERT'; 47 48 49 COMMIT;