challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

challenger-0004.sql (2017B)


      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-0004', NULL, NULL);
     22 
     23 SET search_path TO challenger;
     24 
     25 -- need to drop this before converting UNIQUE to PK
     26 ALTER TABLE validations
     27   DROP CONSTRAINT validations_client_serial_id_fkey;
     28 
     29 -- convert UNIQUE index to PK
     30 ALTER TABLE clients
     31   ADD CONSTRAINT clients_serial_pkey PRIMARY KEY (client_serial_id),
     32   DROP CONSTRAINT clients_client_serial_id_key;
     33 
     34 -- Set non-NULLable where the C code reads
     35 -- fields through non-nullable result specs,
     36 -- add missing pK, and re-add foreign key constraint
     37 ALTER TABLE validations
     38   ALTER COLUMN nonce SET NOT NULL,
     39   ALTER COLUMN address_attempts_left SET NOT NULL,
     40   ALTER COLUMN pin_transmissions_left SET NOT NULL,
     41   ALTER COLUMN auth_attempts_left SET NOT NULL,
     42   ADD CONSTRAINT validation_serial_pkey PRIMARY KEY (validation_serial_id),
     43   ADD CONSTRAINT validations_client_serial_id_fkey
     44     FOREIGN KEY (client_serial_id)
     45     REFERENCES clients(client_serial_id)
     46     ON DELETE CASCADE;
     47 
     48 -- Add missing index for FK cascade drop
     49 CREATE INDEX validations_by_client
     50   ON validations(client_serial_id);
     51 COMMENT ON INDEX validations_by_client
     52   IS 'Index needed for foreign key constraint validations_client_serial_id_fkey';
     53 
     54 
     55 COMMIT;