diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-09-16 20:48:25 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-09-16 20:48:25 +0200 |
commit | 7045d3df1694d92c98369402adee675238833d6c (patch) | |
tree | a9925390f9261413b8d57651e043ba5a0e36d609 /src/exchangedb/0002-reserves_out.sql | |
parent | 94a313d74b403f7afa130a999ab2171414f86a46 (diff) | |
download | exchange-7045d3df1694d92c98369402adee675238833d6c.tar.xz |
add triggers to populate reserve history table
Diffstat (limited to 'src/exchangedb/0002-reserves_out.sql')
-rw-r--r-- | src/exchangedb/0002-reserves_out.sql | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/exchangedb/0002-reserves_out.sql b/src/exchangedb/0002-reserves_out.sql index 7c5cf554c..1e4038957 100644 --- a/src/exchangedb/0002-reserves_out.sql +++ b/src/exchangedb/0002-reserves_out.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2022 Taler Systems SA +-- Copyright (C) 2014--2023 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 @@ -157,12 +157,23 @@ CREATE FUNCTION reserves_out_by_reserve_insert_trigger() LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO exchange.reserves_out_by_reserve + INSERT INTO reserves_out_by_reserve (reserve_uuid ,h_blind_ev) VALUES (NEW.reserve_uuid ,NEW.h_blind_ev); + INSERT INTO reserve_history + (reserve_pub + ,table_name + ,serial_id) + SELECT + res.reserve_pub + ,'reserves_out' + ,NEW.reserve_out_serial_id + FROM + reserves res + WHERE res.reserve_uuid = NEW.reserve_uuid; RETURN NEW; END $$; COMMENT ON FUNCTION reserves_out_by_reserve_insert_trigger() @@ -174,7 +185,7 @@ CREATE FUNCTION reserves_out_by_reserve_delete_trigger() LANGUAGE plpgsql AS $$ BEGIN - DELETE FROM exchange.reserves_out_by_reserve + DELETE FROM reserves_out_by_reserve WHERE reserve_uuid = OLD.reserve_uuid; RETURN OLD; END $$; |