0005-auditor_historic_denomination_revenue.sql (2069B)
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 -- A denomination can be credited after the auditor booked its remaining 18 -- balance as revenue: an expiring purse refunds the coins deposited into 19 -- it, and /recoup-refresh credits the old coin of a refresh, neither of 20 -- which checks the expiration of the denomination. The additional 21 -- revenue has to be recorded without rewriting a row that 22 -- /monitoring/historic-denomination-revenue may already have handed out 23 -- -- that endpoint pages the table by row_id, so a consumer that is past 24 -- a row would never see the change. The table therefore becomes 25 -- append-only: row_id is the primary key and denom_pub_hash is merely 26 -- indexed, so that a late settlement is a new, final row. 27 ALTER TABLE auditor_historic_denomination_revenue 28 DROP CONSTRAINT auditor_historic_denomination_revenue_pkey 29 ,DROP CONSTRAINT auditor_historic_denomination_revenue_row_id_key 30 ,ADD PRIMARY KEY (row_id); 31 CREATE INDEX auditor_historic_denomination_revenue_by_denom_pub_hash 32 ON auditor_historic_denomination_revenue 33 (denom_pub_hash); 34 COMMENT ON COLUMN auditor_historic_denomination_revenue.denom_pub_hash 35 IS 'hash of the denomination public key that created this revenue; since auditor-0005 there can be more than one row per denomination, as a credit that arrives after the denomination was booked as finished is appended instead of changing the row that was booked';