diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-09-16 14:04:36 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-09-16 14:04:36 +0200 |
commit | 94a313d74b403f7afa130a999ab2171414f86a46 (patch) | |
tree | 74a5b4cdaaf84d93e89a56372bbac51673d1bbb6 /src/exchangedb/0002-purse_deposits.sql | |
parent | 82f353ce4e3c19f01fcf078b76ae613550673c75 (diff) | |
download | exchange-94a313d74b403f7afa130a999ab2171414f86a46.tar.xz |
create coin history table via triggers
Diffstat (limited to 'src/exchangedb/0002-purse_deposits.sql')
-rw-r--r-- | src/exchangedb/0002-purse_deposits.sql | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/exchangedb/0002-purse_deposits.sql b/src/exchangedb/0002-purse_deposits.sql index e83e07382..2d2be5152 100644 --- a/src/exchangedb/0002-purse_deposits.sql +++ b/src/exchangedb/0002-purse_deposits.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 @@ -121,6 +121,37 @@ END $$; +CREATE OR REPLACE FUNCTION purse_deposits_insert_trigger() + RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + INSERT INTO exchange.coin_history + (coin_pub + ,table_name + ,serial_id) + VALUES + (NEW.coin_pub + ,'purse_deposits' + ,NEW.purse_deposit_serial_id); + RETURN NEW; +END $$; +COMMENT ON FUNCTION purse_deposits_insert_trigger() + IS 'Automatically generate coin history entry.'; + + +CREATE FUNCTION master_table_purse_deposits() +RETURNS VOID +LANGUAGE plpgsql +AS $$ +BEGIN + CREATE TRIGGER purse_deposits_on_insert + AFTER INSERT + ON purse_deposits + FOR EACH ROW EXECUTE FUNCTION purse_deposits_insert_trigger(); +END $$; + + INSERT INTO exchange_tables (name ,version @@ -142,4 +173,9 @@ INSERT INTO exchange_tables ,'exchange-0002' ,'foreign' ,TRUE + ,FALSE), + ('purse_deposits' + ,'exchange-0002' + ,'master' + ,TRUE ,FALSE); |