aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange-0001-part.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/exchange-0001-part.sql')
-rw-r--r--src/exchangedb/exchange-0001-part.sql33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index ba54f6f7..7e2547db 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -539,10 +539,10 @@ SELECT add_constraints_to_refresh_transfer_keys_partition('default');
-- ------------------------------ policy_fulfilments -------------------------------------
CREATE TABLE IF NOT EXISTS policy_fulfilments
- (policy_fulfilments_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
+ (fulfilment_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
,fulfilment_timestamp INT8 NOT NULL
,fulfilment_proof VARCHAR)
- PARTITION BY HASH (policy_fulfilments_serial_id);
+ PARTITION BY HASH (fulfilment_id);
COMMENT ON TABLE policy_fulfilments
IS 'Proofs of fulfilment of policies that were set in deposits';
COMMENT ON COLUMN policy_fulfilments.fulfilment_timestamp
@@ -554,14 +554,14 @@ CREATE TABLE IF NOT EXISTS policy_fulfilments_default
PARTITION OF policy_fulfilments
FOR VALUES WITH (MODULUS 1, REMAINDER 0);
-
-- ------------------------------ policy_details ----------------------------------------
CREATE TABLE IF NOT EXISTS policy_details
(policy_details_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY
,serial_id BYTEA PRIMARY KEY CHECK(LENGTH(serial_id)=64)
,policy_options VARCHAR
- ,fulfilment_serial_id BIGINT REFERENCES policy_fulfilments(policy_fulfilments_serial_id) ON DELETE CASCADE)
+ ,deadline INT8 NOT NULL
+ ,fulfilment_state INT4 NOT NULL CHECK(fulfilment_state between 0 and 3))
PARTITION BY HASH (serial_id);
COMMENT ON TABLE policy_details
IS 'Policies that were provided with deposits via policy extensions.';
@@ -569,13 +569,34 @@ COMMENT ON COLUMN policy_details.serial_id
IS 'ID (GNUNET_HashCode) that identifies a policy. Will be calculated by the policy extension based on the content';
COMMENT ON COLUMN policy_details.policy_options
IS 'JSON object with options set that the exchange needs to consider when executing a deposit. Supported details depend on the policy extensions supported by the exchange.';
-COMMENT ON COLUMN policy_details.fulfilment_serial_id
- IS 'If not NULL, refers to the proof of fulfilment of this policy';
+COMMENT ON COLUMN policy_details.deadline
+ IS 'Deadline until the policy must be marked as fulfilled or unfulfilled (maybe "forever")';
+COMMENT ON COLUMN policy_details.fulfilment_state
+ IS 'State of the fulfilment: 0 (PENDING), 1 (FULFILLED), 2 (NOT FULFILLED), 3 (TIMED OUT)';
CREATE TABLE IF NOT EXISTS policy_details_default
PARTITION OF policy_details
FOR VALUES WITH (MODULUS 1, REMAINDER 0);
+-- ------------------------------ policy_details_fulfilments -----------------------------
+
+CREATE TABLE IF NOT EXISTS policy_details_fulfilments
+ (fulfilment_id BIGINT NOT NULL REFERENCES policy_fulfilments(fulfilment_id) ON DELETE CASCADE
+ ,serial_id BYTEA NOT NULL UNIQUE REFERENCES policy_details(serial_id) ON DELETE CASCADE)
+ PARTITION BY HASH (serial_id); -- FIXME: choose other thing to hash here?
+-- FIXME: define a primary key here?
+COMMENT ON TABLE policy_details_fulfilments
+ IS 'Links policy_details.serial_id''s with policy_fulfilments.id''s. The same proof of fulfilment can be associated with multiple serial-id''s';
+COMMENT ON COLUMN policy_details_fulfilments.fulfilment_id
+ IS 'ID of the proof of fulfilment';
+COMMENT ON COLUMN policy_details_fulfilments.serial_id
+ IS 'Serial-ID of the corresponding policy_detail';
+
+CREATE TABLE IF NOT EXISTS policy_details_fulfilments_default
+ PARTITION OF policy_details_fulfilments
+ FOR VALUES WITH (MODULUS 1, REMAINDER 0);
+
+
-- ------------------------------ deposits ----------------------------------------
SELECT create_table_deposits();