From fcfb417bd63bbf333e0934ff1857b9584784c5db Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Thu, 9 Feb 2023 11:24:29 +0700 Subject: [PATCH] Tables --- tables.sql | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tables.sql diff --git a/tables.sql b/tables.sql new file mode 100644 index 0000000..fdc7460 --- /dev/null +++ b/tables.sql @@ -0,0 +1,58 @@ +CREATE TABLE users ( + id serial not null primary key, + name varchar(32) not null, +); + +CREATE TABLE resource( + id serial not null primary key, + name varchar(32) not null, +); + +INSERT INTO resource(name) VALUES + ('NEBULANCE'), + ('SHADOWSTONE'), + ('AZURIUM'), + ('NOVAFOR'), + ('SOLLUX'); + +CREATE TABLE staking_source( + id serial not null primary key, + user_id int not null, + CONSTRAINT fk_user FOREIGN KEY(user_id) + REFERENCES users(id), +); + +CREATE TABLE resource_well( + id serial not null primary key, + staking_source_id int not null, + resource_id int not null, + init_supply int not null default 0, + CONSTRAINT fk_resource FOREIGN KEY(resource_id) + REFERENCES resource(id), + CONSTRAINT fk_ssource FOREIGN KEY(staking_source_id) + REFERENCES staking_source(id), +); + +CREATE TABLE staking_event( + id serial primary key not null, + staking_source_id int not null, + created_at timestamp without time zone default (now() at time zone 'utc'), + CONSTRAINT fk_ures FOREIGN KEY(staking_source_id) + REFERENCES staking_source(id), +); + +CREATE TABLE upgrade_event( + id serial primary key not null, + staking_event_id int not null, + created_at timestamp without time zone default (now() at time zone 'utc'), + CONSTRAINT fk_mevent FOREIGN KEY(staking_event_id) + REFERENCES staking_event(id), +); + +CREATE TABLE claim_event( + id serial not null primary key, + staking_source_id int not null, + created_at timestamp without time zone default (now() at time zone 'utc'), + CONSTRAINT fk_ures FOREIGN KEY(staking_source_id) + REFERENCES staking_source(id), +);