[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: -add a few missing indices/forei
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: -add a few missing indices/foreign key constraints |
Date: |
Wed, 11 Jan 2023 16:43:25 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new af06ddc8 -add a few missing indices/foreign key constraints
af06ddc8 is described below
commit af06ddc8e833d6f4bbfd49585a750227b05c056d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Jan 11 16:43:22 2023 +0100
-add a few missing indices/foreign key constraints
---
src/exchangedb/0002-history_requests.sql | 27 +++++++++++++++++++++-
src/exchangedb/0002-legitimization_processes.sql | 2 +-
.../0002-legitimization_requirements.sql | 2 +-
src/exchangedb/0002-refresh_commitments.sql | 2 +-
src/exchangedb/0002-reserves_in.sql | 24 +++++++++++++++++--
src/exchangedb/0003-withdraw_age_commitments.sql | 2 +-
6 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/src/exchangedb/0002-history_requests.sql
b/src/exchangedb/0002-history_requests.sql
index 5cd5c7b7..853a435d 100644
--- a/src/exchangedb/0002-history_requests.sql
+++ b/src/exchangedb/0002-history_requests.sql
@@ -26,7 +26,7 @@ DECLARE
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I '
- '(history_request_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
--UNIQUE
+ '(history_request_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
',reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32)'
',request_timestamp INT8 NOT NULL'
',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)'
@@ -64,6 +64,26 @@ BEGIN
END $$;
+CREATE FUNCTION constrain_table_history_requests(
+ IN partition_suffix VARCHAR
+)
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ partition_name VARCHAR;
+BEGIN
+ partition_name = concat_ws('_', 'history_requests', partition_suffix);
+
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || partition_name ||
+ ' ADD CONSTRAINT ' || partition_name || '_serial_id'
+ ' UNIQUE (history_request_serial_id)'
+ );
+END
+$$;
+
+
CREATE FUNCTION foreign_table_history_requests()
RETURNS VOID
LANGUAGE plpgsql
@@ -94,6 +114,11 @@ INSERT INTO exchange_tables
,FALSE),
('history_requests'
,'exchange-0002'
+ ,'constrain'
+ ,TRUE
+ ,FALSE),
+ ('history_requests'
+ ,'exchange-0002'
,'foreign'
,TRUE
,FALSE);
diff --git a/src/exchangedb/0002-legitimization_processes.sql
b/src/exchangedb/0002-legitimization_processes.sql
index 6248da1f..4544a02e 100644
--- a/src/exchangedb/0002-legitimization_processes.sql
+++ b/src/exchangedb/0002-legitimization_processes.sql
@@ -23,7 +23,7 @@ AS $$
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
- '(legitimization_process_serial_id BIGINT GENERATED BY DEFAULT AS
IDENTITY' -- UNIQUE'
+ '(legitimization_process_serial_id BIGINT GENERATED BY DEFAULT AS
IDENTITY'
',h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=32)'
',expiration_time INT8 NOT NULL DEFAULT (0)'
',provider_section VARCHAR NOT NULL'
diff --git a/src/exchangedb/0002-legitimization_requirements.sql
b/src/exchangedb/0002-legitimization_requirements.sql
index 7aaf7b79..4879b7a2 100644
--- a/src/exchangedb/0002-legitimization_requirements.sql
+++ b/src/exchangedb/0002-legitimization_requirements.sql
@@ -23,7 +23,7 @@ AS $$
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
- '(legitimization_requirement_serial_id BIGINT GENERATED BY DEFAULT AS
IDENTITY' -- UNIQUE'
+ '(legitimization_requirement_serial_id BIGINT GENERATED BY DEFAULT AS
IDENTITY'
',h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=32)'
',required_checks VARCHAR NOT NULL'
',UNIQUE (h_payto, required_checks)'
diff --git a/src/exchangedb/0002-refresh_commitments.sql
b/src/exchangedb/0002-refresh_commitments.sql
index c63995c7..328dad5c 100644
--- a/src/exchangedb/0002-refresh_commitments.sql
+++ b/src/exchangedb/0002-refresh_commitments.sql
@@ -25,7 +25,7 @@ DECLARE
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
- '(melt_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE'
+ '(melt_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
',rc BYTEA PRIMARY KEY CHECK (LENGTH(rc)=64)'
',old_coin_pub BYTEA NOT NULL'
',old_coin_sig BYTEA NOT NULL CHECK(LENGTH(old_coin_sig)=64)'
diff --git a/src/exchangedb/0002-reserves_in.sql
b/src/exchangedb/0002-reserves_in.sql
index d722a49e..71ec3768 100644
--- a/src/exchangedb/0002-reserves_in.sql
+++ b/src/exchangedb/0002-reserves_in.sql
@@ -25,8 +25,8 @@ DECLARE
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
- '(reserve_in_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' --
UNIQUE'
- ',reserve_pub BYTEA PRIMARY KEY' -- REFERENCES reserves (reserve_pub) ON
DELETE CASCADE'
+ '(reserve_in_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
+ ',reserve_pub BYTEA PRIMARY KEY'
',wire_reference INT8 NOT NULL'
',credit_val INT8 NOT NULL'
',credit_frac INT4 NOT NULL'
@@ -103,6 +103,21 @@ BEGIN
END
$$;
+CREATE FUNCTION foreign_table_reserves_in()
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'reserves_in';
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_reserve_pub'
+ ' FOREIGN KEY (reserve_pub) '
+ ' REFERENCES reserves(reserve_pub) ON DELETE CASCADE'
+ );
+END $$;
+
INSERT INTO exchange_tables
(name
@@ -120,4 +135,9 @@ INSERT INTO exchange_tables
,'exchange-0002'
,'constrain'
,TRUE
+ ,FALSE),
+ ('reserves_in'
+ ,'exchange-0002'
+ ,'foreign'
+ ,TRUE
,FALSE);
diff --git a/src/exchangedb/0003-withdraw_age_commitments.sql
b/src/exchangedb/0003-withdraw_age_commitments.sql
index e2205b12..f6f8b44d 100644
--- a/src/exchangedb/0003-withdraw_age_commitments.sql
+++ b/src/exchangedb/0003-withdraw_age_commitments.sql
@@ -25,7 +25,7 @@ DECLARE
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
- '(withdraw_age_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY' --
UNIQUE'
+ '(withdraw_age_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
',h_commitment BYTEA PRIMARY KEY CHECK (LENGTH(h_commitment)=64)'
',amount_with_fee_val INT8 NOT NULL'
',amount_with_fee_frac INT4 NOT NULL'
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: -add a few missing indices/foreign key constraints,
gnunet <=