0004-auditor_pending_deposits.sql (1390B)
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 -- delete_pending_deposit() deletes by batch_deposit_serial_id and its 18 -- caller (clear_finished_transfer_cb) asserts that at most one row was 19 -- removed, but insert_pending_deposit() had no dedup and the column had 20 -- no unique index. Drop the duplicates (keeping the most recent report 21 -- for each deposit) and constrain the column. 22 DELETE FROM auditor_pending_deposits ap 23 WHERE ap.row_id < 24 (SELECT MAX(ap2.row_id) 25 FROM auditor_pending_deposits ap2 26 WHERE ap2.batch_deposit_serial_id=ap.batch_deposit_serial_id); 27 28 ALTER TABLE auditor_pending_deposits 29 ADD CONSTRAINT auditor_pending_deposits_batch_deposit_serial_id_key 30 UNIQUE (batch_deposit_serial_id);