summaryrefslogtreecommitdiff
path: root/src/exchangedb/0002-reserves_open_deposits.sql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-09-16 14:04:36 +0200
committerChristian Grothoff <christian@grothoff.org>2023-09-16 14:04:36 +0200
commit94a313d74b403f7afa130a999ab2171414f86a46 (patch)
tree74a5b4cdaaf84d93e89a56372bbac51673d1bbb6 /src/exchangedb/0002-reserves_open_deposits.sql
parent82f353ce4e3c19f01fcf078b76ae613550673c75 (diff)
downloadexchange-94a313d74b403f7afa130a999ab2171414f86a46.tar.gz
exchange-94a313d74b403f7afa130a999ab2171414f86a46.tar.bz2
exchange-94a313d74b403f7afa130a999ab2171414f86a46.zip
create coin history table via triggers
Diffstat (limited to 'src/exchangedb/0002-reserves_open_deposits.sql')
-rw-r--r--src/exchangedb/0002-reserves_open_deposits.sql38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/exchangedb/0002-reserves_open_deposits.sql b/src/exchangedb/0002-reserves_open_deposits.sql
index b1a292dd4..776859df8 100644
--- a/src/exchangedb/0002-reserves_open_deposits.sql
+++ b/src/exchangedb/0002-reserves_open_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
@@ -80,6 +80,37 @@ END
$$;
+CREATE OR REPLACE FUNCTION reserves_open_deposits_insert_trigger()
+ RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+BEGIN
+ INSERT INTO exchange.coin_history
+ (coin_pub
+ ,table_name
+ ,serial_id)
+ VALUES
+ (NEW.coin_pub
+ ,'reserves_open_deposits'
+ ,NEW.reserve_open_deposit_uuid);
+ RETURN NEW;
+END $$;
+COMMENT ON FUNCTION reserves_open_deposits_insert_trigger()
+ IS 'Automatically generate coin history entry.';
+
+
+CREATE FUNCTION master_table_reserves_open_deposits()
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ CREATE TRIGGER reserves_open_deposits_on_insert
+ AFTER INSERT
+ ON reserves_open_deposits
+ FOR EACH ROW EXECUTE FUNCTION reserves_open_deposits_insert_trigger();
+END $$;
+
+
INSERT INTO exchange_tables
(name
,version
@@ -96,4 +127,9 @@ INSERT INTO exchange_tables
,'exchange-0002'
,'constrain'
,TRUE
+ ,FALSE),
+ ('reserves_open_deposits'
+ ,'exchange-0002'
+ ,'master'
+ ,TRUE
,FALSE);