From 94a313d74b403f7afa130a999ab2171414f86a46 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Sat, 16 Sep 2023 14:04:36 +0200
Subject: create coin history table via triggers

---
 src/exchangedb/0002-recoup.sql | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'src/exchangedb/0002-recoup.sql')

diff --git a/src/exchangedb/0002-recoup.sql b/src/exchangedb/0002-recoup.sql
index c3f96f498..600091b61 100644
--- a/src/exchangedb/0002-recoup.sql
+++ b/src/exchangedb/0002-recoup.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
@@ -171,10 +171,18 @@ BEGIN
   VALUES
     (NEW.reserve_out_serial_id
     ,NEW.coin_pub);
-  RETURN NEW;
+  INSERT INTO exchange.coin_history
+    (coin_pub
+    ,table_name
+    ,serial_id)
+  VALUES
+    (NEW.coin_pub
+    ,'recoup'
+    ,NEW.recoup_uuid);
+ RETURN NEW;
 END $$;
 COMMENT ON FUNCTION recoup_insert_trigger()
-  IS 'Replicate recoup inserts into recoup_by_reserve table.';
+  IS 'Replicates recoup inserts into recoup_by_reserve table and updates the coin_history table.';
 
 
 CREATE FUNCTION recoup_delete_trigger()
-- 
cgit v1.2.3

