aboutsummaryrefslogtreecommitdiff
path: root/src/auditordb/auditor-0001.sql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-11-02 17:51:42 +0100
committerChristian Grothoff <christian@grothoff.org>2022-11-02 17:51:42 +0100
commita51517f64c83c23545ebd8a935baa311f0de635a (patch)
tree8431dcad0c9aa743468b551828be021a1378f4a6 /src/auditordb/auditor-0001.sql
parent5c0b8e32406a7e000396003e9428a1cf9af3e919 (diff)
-implement missing functions
Diffstat (limited to 'src/auditordb/auditor-0001.sql')
-rw-r--r--src/auditordb/auditor-0001.sql18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql
index 7bd5531e8..a19655d42 100644
--- a/src/auditordb/auditor-0001.sql
+++ b/src/auditordb/auditor-0001.sql
@@ -170,8 +170,8 @@ CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
CREATE TABLE IF NOT EXISTS auditor_purses
(purse_pub BYTEA NOT NULL CHECK(LENGTH(purse_pub)=32)
,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,balance_val INT8 NOT NULL
- ,balance_frac INT4 NOT NULL
+ ,balance_val INT8 NOT NULL DEFAULT(0)
+ ,balance_frac INT4 NOT NULL DEFAULT(0)
,target_val INT8 NOT NULL
,target_frac INT4 NOT NULL
,expiration_date INT8 NOT NULL
@@ -185,6 +185,20 @@ CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub
(purse_pub);
+CREATE TABLE IF NOT EXISTS auditor_purse_summary
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ ,balance_val INT8 NOT NULL
+ ,balance_frac INT4 NOT NULL
+ ,open_purses INT8 NOT NULL
+ );
+COMMENT ON TABLE auditor_purse_summary
+ IS 'sum of the balances in open purses';
+
+CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub
+ ON auditor_purses
+ (purse_pub);
+
+
CREATE TABLE IF NOT EXISTS auditor_reserve_balance
(master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,reserve_balance_val INT8 NOT NULL