From 6fd6db473bce40f64fd5c1cd55f4864e3beabc76 Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sun, 8 Jul 2018 11:44:24 -0600 Subject: [PATCH] server: Add the AMOUNT_TYPE domain to the evolution schema (#35) --- server/conf/evolutions/default/1.sql | 3 +++ server/conf/evolutions/default/3.sql | 4 ++-- server/conf/evolutions/default/4.sql | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/conf/evolutions/default/1.sql b/server/conf/evolutions/default/1.sql index 442bb82..80dca0b 100644 --- a/server/conf/evolutions/default/1.sql +++ b/server/conf/evolutions/default/1.sql @@ -23,8 +23,11 @@ CHECK ( VALUE >= 0 ); +CREATE DOMAIN AMOUNT_TYPE AS DECIMAL(30, 15); + # --- !Downs +DROP DOMAIN AMOUNT_TYPE; DROP DOMAIN NON_NEGATIVE_INT_TYPE; DROP DOMAIN ADDRESS_TYPE; DROP DOMAIN TXID_TYPE; diff --git a/server/conf/evolutions/default/3.sql b/server/conf/evolutions/default/3.sql index 8d82378..7c568c3 100644 --- a/server/conf/evolutions/default/3.sql +++ b/server/conf/evolutions/default/3.sql @@ -5,8 +5,8 @@ -- simpler queries while requiring addresses and the available amounts. CREATE TABLE balances( address ADDRESS_TYPE NOT NULL, - received DECIMAL(30, 15) NOT NULL, - spent DECIMAL(30, 15) NOT NULL, + received AMOUNT_TYPE NOT NULL, + spent AMOUNT_TYPE NOT NULL, -- constraints CONSTRAINT balances_address_pk PRIMARY KEY (address) ); diff --git a/server/conf/evolutions/default/4.sql b/server/conf/evolutions/default/4.sql index ece96d3..c792630 100644 --- a/server/conf/evolutions/default/4.sql +++ b/server/conf/evolutions/default/4.sql @@ -18,7 +18,7 @@ CREATE INDEX transactions_time_index ON transactions USING BTREE (time); CREATE TABLE transaction_outputs( txid TXID_TYPE NOT NULL, index NON_NEGATIVE_INT_TYPE NOT NULL, - value DECIMAL(30, 15) NOT NULL, + value AMOUNT_TYPE NOT NULL, address ADDRESS_TYPE NOT NULL, hex_script TEXT NOT NULL, spent_on TXID_TYPE NULL, @@ -39,7 +39,7 @@ CREATE TABLE transaction_inputs( index NON_NEGATIVE_INT_TYPE NOT NULL, from_txid TXID_TYPE NOT NULL, from_output_index NON_NEGATIVE_INT_TYPE NOT NULL, - value DECIMAL(30, 15) NULL, + value AMOUNT_TYPE NULL, address ADDRESS_TYPE NULL, -- constraints CONSTRAINT transaction_inputs_txid_index_pk PRIMARY KEY (txid, index),