From 80f27602f687251a33170624706ed54c05912093 Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sun, 4 Nov 2018 23:16:34 -0700 Subject: [PATCH] server: Add the address_transaction_details table --- server/conf/evolutions/default/6.sql | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 server/conf/evolutions/default/6.sql diff --git a/server/conf/evolutions/default/6.sql b/server/conf/evolutions/default/6.sql new file mode 100644 index 0000000..2f22908 --- /dev/null +++ b/server/conf/evolutions/default/6.sql @@ -0,0 +1,22 @@ + +# --- !Ups + +CREATE TABLE address_transaction_details ( + address ADDRESS_TYPE NOT NULL, + txid TXID_TYPE NOT NULL, + sent AMOUNT_TYPE NOT NULL, + received AMOUNT_TYPE NOT NULL, + time BIGINT NOT NULL, -- it is cheaper to carry this value from the tx than to use joins in each query + -- constraints + CONSTRAINT address_transaction_details_pk PRIMARY KEY (address, txid), + CONSTRAINT address_transaction_details_txid_fk FOREIGN KEY (txid) REFERENCES transactions (txid) +); + +CREATE INDEX address_transaction_details_txid_index ON address_transaction_details USING BTREE (txid); +CREATE INDEX address_transaction_details_time_index ON address_transaction_details USING BTREE (time); + +# --- !Downs + +DROP INDEX address_transaction_details_time_index; +DROP INDEX address_transaction_details_txid_index; +DROP TABLE address_transaction_details;