From 856b8e26c2b83ebce31eb35c9fc9f23641187be9 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Mon, 3 Oct 2022 23:54:12 +0200
Subject: -more work on new DB logic

---
 src/exchangedb/common-0001.sql | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/exchangedb/common-0001.sql')

diff --git a/src/exchangedb/common-0001.sql b/src/exchangedb/common-0001.sql
index 4a0aac38..564bf3b3 100644
--- a/src/exchangedb/common-0001.sql
+++ b/src/exchangedb/common-0001.sql
@@ -459,7 +459,8 @@ BEGIN
   PERFORM create_partitioned_table(
     'CREATE TABLE IF NOT EXISTS %I'
       '(reserve_open_deposit_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE / PRIMARY KEY'
-      ',reserve_pub BYTEA NOT NULL' -- REFERENCES reserves (reserve_pub) ON DELETE CASCADE'
+      ',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)'
+      ',reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=32)'
       ',request_timestamp INT8 NOT NULL'
       ',coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)'
       ',coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64)'
@@ -496,7 +497,7 @@ BEGIN
   EXECUTE FORMAT (
     'ALTER TABLE reserves_open_deposits_' || partition_suffix || ' '
       'ADD CONSTRAINT reserves_open_deposits_' || partition_suffix || '_coin_unique '
-        'PRIMARY KEY (coin_pub,reserve_pub)'
+        'PRIMARY KEY (coin_pub,coin_sig)'
   );
 END
 $$;
@@ -1749,6 +1750,9 @@ BEGIN
       ',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)'
       ',close_val INT8 NOT NULL'
       ',close_frac INT4 NOT NULL'
+      ',close_fee_val INT8 NOT NULL'
+      ',close_fee_frac INT4 NOT NULL'
+      ',payto_uri VARCHAR NOT NULL'
       ',PRIMARY KEY (reserve_pub,close_timestamp)'
     ') %s ;'
     ,table_name
-- 
cgit v1.2.3

