exchange-0019.sql (1712B)
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 BEGIN; 18 19 SELECT _v.register_patch('exchange-0019', NULL, NULL); 20 21 SET search_path TO exchange; 22 23 24 -- Allow one pending alert per account *and* receiver. 25 -- 26 -- kyc_alerts was keyed by h_payto alone, so an account could only have a 27 -- single pending alert, whatever its trigger_type: the alert for a second 28 -- receiver was dropped by the producers' ON CONFLICT DO NOTHING, and the 29 -- first receiver to drain the row deleted it for everybody. Key the table 30 -- by (trigger_type, h_payto) instead, which also makes the old 31 -- UNIQUE (trigger_type, h_payto) redundant. Existing rows satisfy both 32 -- keys, so they are kept as they are. 33 34 ALTER TABLE kyc_alerts 35 DROP CONSTRAINT kyc_alerts_pkey, 36 DROP CONSTRAINT kyc_alerts_trigger_type_h_payto_key; 37 38 ALTER TABLE kyc_alerts 39 ADD PRIMARY KEY (trigger_type, h_payto); 40 41 COMMENT ON TABLE kyc_alerts 42 IS 'alerts about completed KYC events reliably notifying other components (even if they are not running); at most one pending alert per account and receiver'; 43 44 COMMIT;