From 40060686a0266f356687758e8eef59b485254aa4 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 21 Apr 2023 19:26:02 +0700 Subject: [PATCH] Change to floating point numbers for prices and claims --- sql/import-config.sql | 27 +++++++++++++++------------ sql/tables.sql | 16 ++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/sql/import-config.sql b/sql/import-config.sql index fe5843d..52621a4 100644 --- a/sql/import-config.sql +++ b/sql/import-config.sql @@ -6,19 +6,19 @@ begin name text not null, description text not null, image text not null, - claimAmount integer not null, + claimAmount float8 not null, completionTimeInMins integer not null, - basePrice integer not null, - tier_1_price integer not null, - tier_1_claimboost integer not null, - tier_2_price integer not null, - tier_2_claimboost integer not null, - tier_3_price integer not null, - tier_3_claimboost integer not null, - tier_4_price integer not null, - tier_4_claimboost integer not null, - tier_5_price integer not null, - tier_5_claimboost integer not null + basePrice float8 not null, + tier_1_price float8 not null, + tier_1_claimboost float8 not null, + tier_2_price float8 not null, + tier_2_claimboost float8 not null, + tier_3_price float8 not null, + tier_3_claimboost float8 not null, + tier_4_price float8 not null, + tier_4_claimboost float8 not null, + tier_5_price float8 not null, + tier_5_claimboost float8 not null ) on commit drop; create temporary table if not exists stakingSources( id integer primary key, @@ -130,6 +130,9 @@ begin end; $$ language plpgsql; +-- Needed to load the python3 extension +CREATE EXTENSION plpython3u; + create or replace function download_sheets() returns void as $$ import requests diff --git a/sql/tables.sql b/sql/tables.sql index a8578a2..ac5221a 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -18,9 +18,9 @@ create table store_item( id integer primary key, name text not null, description text not null, - price integer not null, + price float8 not null, image_name text not null, - claim_amount integer not null, + claim_amount float8 not null, completion_time_in_mins integer not null ); @@ -28,7 +28,7 @@ create table upgrade_item( tier integer not null, store_item_id integer not null, price text not null, - claim_boost integer not null, + claim_boost float8 not null, constraint fk_store_item_upgrade_item foreign key(store_item_id) references store_item(id) on delete cascade, primary key (store_item_id, tier) @@ -57,7 +57,7 @@ create table resource_well ( id uuid primary key default gen_random_uuid(), resource_id integer not null, source_id uuid not null, - supply integer not null, + supply float8 not null, constraint fk_sid_resource_well foreign key(source_id) references staking_source(id) on delete cascade, constraint fk_rid_resource_well foreign key(resource_id) @@ -91,7 +91,7 @@ create table staking_event ( well_id uuid not null, inventory_item_id uuid not null, duration_in_mins integer not null, - stake_amount integer not null, + stake_amount float8 not null, created_at timestamp with time zone default timezone('utc', now()), constraint fk_user_staking_event foreign key(user_id) references users(id) on delete cascade, @@ -104,7 +104,7 @@ create table staking_event ( create table claim_event ( id uuid primary key default gen_random_uuid(), staking_event_id uuid not null, - claim_amount integer not null, + claim_amount float8 not null, created_at timestamp with time zone default timezone('utc', now()), constraint fk_se_claim_event foreign key(staking_event_id) references staking_event(id) on delete cascade @@ -113,7 +113,7 @@ create table claim_event ( create table bank_account ( id uuid primary key default gen_random_uuid(), user_id uuid not null, - balance integer not null default 0 check (balance >= 0), + balance float8 not null default 0 check (balance >= 0), constraint fk_user_bank_account foreign key(user_id) references users(id) on delete cascade ); @@ -122,7 +122,7 @@ create table resource_account ( id uuid primary key default gen_random_uuid(), resource_id integer not null, user_id uuid not null, - balance integer not null default 0 check (balance >= 0), + balance float8 not null default 0 check (balance >= 0), constraint fk_user_resource_account foreign key(user_id) references users(id) on delete cascade, constraint fk_rid_resource_account foreign key(resource_id)