commit da8729819a0a91edd5f5d4ad8c801b609d2ac615
parent 4d40e5a4aa2047c2fd5b055a30797835752443e2
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 7 Aug 2026 00:39:12 +0200
squash unreleased DB migrations into one
Diffstat:
4 files changed, 23 insertions(+), 69 deletions(-)
diff --git a/src/donaudb/donau-0003.sql b/src/donaudb/donau-0003.sql
@@ -31,4 +31,27 @@ ALTER TABLE history
COMMENT ON COLUMN history.donation_year
IS 'Year the final_amount was accumulated in; part of the primary key.';
+-- receipts_issued.receipt_id was GENERATED BY DEFAULT AS IDENTITY, which
+-- permits explicit inserts (bulk load, partial restore, ad-hoc migration)
+-- and thus permits leaving the identity sequence behind the largest stored
+-- value. Every subsequent insert then fails with a unique violation on
+-- receipts_issued_receipt_id_key -- which donau-httpd cannot distinguish
+-- from "this receipt_hash already exists". The value is never supplied by
+-- the daemon, so make it unforgeable from the outside.
+ALTER TABLE receipts_issued
+ ALTER COLUMN receipt_id SET GENERATED ALWAYS;
+
+-- receipts_issued.receipt_hash is the idempotence key of POST /batch-issue:
+-- it is what stops a charity from having the same blinded UDIs signed twice.
+-- With ON DELETE CASCADE that guarantee lasted only as long as the charity
+-- row: deleting and re-registering a charity freed every one of its receipt
+-- hashes for replay, and destroyed the record of what had been issued.
+ALTER TABLE receipts_issued
+ DROP CONSTRAINT receipts_issued_charity_id_fkey;
+ALTER TABLE receipts_issued
+ ADD CONSTRAINT receipts_issued_charity_id_fkey
+ FOREIGN KEY (charity_id)
+ REFERENCES charities (charity_id)
+ ON DELETE RESTRICT;
+
COMMIT;
diff --git a/src/donaudb/donau-0004.sql b/src/donaudb/donau-0004.sql
@@ -1,32 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2026 Taler Systems SA
---
--- TALER 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.
---
--- TALER 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
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-BEGIN;
-
-SELECT _v.register_patch('donau-0004', NULL, NULL);
-SET search_path TO donau;
-
--- receipts_issued.receipt_id was GENERATED BY DEFAULT AS IDENTITY, which
--- permits explicit inserts (bulk load, partial restore, ad-hoc migration)
--- and thus permits leaving the identity sequence behind the largest stored
--- value. Every subsequent insert then fails with a unique violation on
--- receipts_issued_receipt_id_key -- which donau-httpd cannot distinguish
--- from "this receipt_hash already exists". The value is never supplied by
--- the daemon, so make it unforgeable from the outside.
-ALTER TABLE receipts_issued
- ALTER COLUMN receipt_id SET GENERATED ALWAYS;
-
-COMMIT;
diff --git a/src/donaudb/donau-0005.sql b/src/donaudb/donau-0005.sql
@@ -1,35 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2026 Taler Systems SA
---
--- TALER 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.
---
--- TALER 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
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-BEGIN;
-
-SELECT _v.register_patch('donau-0005', NULL, NULL);
-SET search_path TO donau;
-
--- receipts_issued.receipt_hash is the idempotence key of POST /batch-issue:
--- it is what stops a charity from having the same blinded UDIs signed twice.
--- With ON DELETE CASCADE that guarantee lasted only as long as the charity
--- row: deleting and re-registering a charity freed every one of its receipt
--- hashes for replay, and destroyed the record of what had been issued.
-ALTER TABLE receipts_issued
- DROP CONSTRAINT receipts_issued_charity_id_fkey;
-ALTER TABLE receipts_issued
- ADD CONSTRAINT receipts_issued_charity_id_fkey
- FOREIGN KEY (charity_id)
- REFERENCES charities (charity_id)
- ON DELETE RESTRICT;
-
-COMMIT;
diff --git a/src/donaudb/meson.build b/src/donaudb/meson.build
@@ -33,8 +33,6 @@ generated_sql = [
['donau-0001.sql', ['donau-0001.sql']],
['donau-0002.sql', donau_0002],
['donau-0003.sql', ['donau-0003.sql']],
- ['donau-0004.sql', ['donau-0004.sql']],
- ['donau-0005.sql', ['donau-0005.sql']],
]