commit 6f88d19cc8edbf04cc36cf0d1ff5de9ce322c234
parent 639d0ff3de76125cd55f04e2851a7e1e86d93de1
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Mon, 13 Jul 2026 20:44:01 +0200
add NOT NULL constrainsts the code expects, support client deletion by cascading ON DELETE
Diffstat:
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/challengerdb/challenger-0004.sql b/src/challengerdb/challenger-0004.sql
@@ -0,0 +1,46 @@
+--
+-- This file is part of Challenger
+-- Copyright (C) 2026 Taler Systems SA
+--
+-- Challenger is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+-- Everything in one big transaction
+BEGIN;
+
+-- Check patch versioning is in place.
+SELECT _v.register_patch('challenger-0004', NULL, NULL);
+
+SET search_path TO challenger;
+
+-- The nonce is the primary lookup key for validations and must always exist.
+ALTER TABLE validations
+ ALTER COLUMN nonce SET NOT NULL;
+
+-- The C code reads these counters through non-nullable uint32 result specs.
+ALTER TABLE validations
+ ALTER COLUMN address_attempts_left SET NOT NULL,
+ ALTER COLUMN pin_transmissions_left SET NOT NULL,
+ ALTER COLUMN auth_attempts_left SET NOT NULL;
+
+-- Deleting a client should remove its ephemeral validations rather than raise
+-- a foreign-key violation that the admin tool surfaces as an internal error.
+-- (The default constraint name for the FK declared inline in challenger-0001
+-- is validations_client_serial_id_fkey.)
+ALTER TABLE validations
+ DROP CONSTRAINT validations_client_serial_id_fkey,
+ ADD CONSTRAINT validations_client_serial_id_fkey
+ FOREIGN KEY (client_serial_id)
+ REFERENCES clients (client_serial_id)
+ ON DELETE CASCADE;
+
+COMMIT;
diff --git a/src/challengerdb/meson.build b/src/challengerdb/meson.build
@@ -19,6 +19,7 @@ generated_sql = [
['challenger-0001.sql', ['challenger-0001.sql']],
['challenger-0002.sql', ['challenger-0002.sql']],
['challenger-0003.sql', ['challenger-0003.sql']],
+ ['challenger-0004.sql', ['challenger-0004.sql']],
]
foreach g : generated_sql