diff options
Diffstat (limited to 'src/exchangedb/0002-reserves.sql')
-rw-r--r-- | src/exchangedb/0002-reserves.sql | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/exchangedb/0002-reserves.sql b/src/exchangedb/0002-reserves.sql index 03d17aee2..d710dd01b 100644 --- a/src/exchangedb/0002-reserves.sql +++ b/src/exchangedb/0002-reserves.sql @@ -15,23 +15,22 @@ -- CREATE FUNCTION create_table_reserves( - IN partition_suffix VARCHAR DEFAULT NULL + IN partition_suffix TEXT DEFAULT NULL ) RETURNS VOID LANGUAGE plpgsql AS $$ DECLARE - table_name VARCHAR DEFAULT 'reserves'; + table_name TEXT DEFAULT 'reserves'; BEGIN PERFORM create_partitioned_table( 'CREATE TABLE %I' '(reserve_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY' ',reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)' - ',current_balance_val INT8 NOT NULL DEFAULT(0)' - ',current_balance_frac INT4 NOT NULL DEFAULT(0)' + ',current_balance taler_amount NOT NULL DEFAULT (0, 0)' ',purses_active INT8 NOT NULL DEFAULT(0)' ',purses_allowed INT8 NOT NULL DEFAULT(0)' - ',max_age INT4 NOT NULL DEFAULT(120)' + ',birthday INT4 NOT NULL DEFAULT(0)' ',expiration_date INT8 NOT NULL' ',gc_date INT8 NOT NULL' ') %s ;' @@ -52,7 +51,7 @@ BEGIN ); PERFORM comment_partitioned_column( 'Current balance remaining with the reserve.' - ,'current_balance_val' + ,'current_balance' ,table_name ,partition_suffix ); @@ -80,18 +79,24 @@ BEGIN ,table_name ,partition_suffix ); + PERFORM comment_partitioned_column( + 'Birthday of the user in days after 1970, or 0 if user is an adult and is not subject to age restrictions' + ,'birthday' + ,table_name + ,partition_suffix + ); END $$; CREATE FUNCTION constrain_table_reserves( - IN partition_suffix VARCHAR + IN partition_suffix TEXT ) RETURNS void LANGUAGE plpgsql AS $$ DECLARE - table_name VARCHAR DEFAULT 'reserves'; + table_name TEXT DEFAULT 'reserves'; BEGIN table_name = concat_ws('_', table_name, partition_suffix); EXECUTE FORMAT ( @@ -103,8 +108,7 @@ BEGIN 'CREATE INDEX ' || table_name || '_by_expiration_index ' 'ON ' || table_name || ' ' '(expiration_date' - ',current_balance_val' - ',current_balance_frac' + ',current_balance' ');' ); EXECUTE FORMAT ( |