Fix some SQL

This commit is contained in:
Joseph Ferano 2023-02-20 12:49:24 +07:00
parent 852f134e47
commit bdf58a624f
2 changed files with 18 additions and 14 deletions

View File

@ -1,9 +1,9 @@
INSERT INTO resource(name) VALUES
('NEBULANCE'),
('SOLLUX'),
('SHADOWSTONE'),
('AZURIUM'),
('NOVAFOR'),
('SOLLUX');
('NEBULANCE');
INSERT INTO users(name) VALUES
('Joe'),
@ -14,20 +14,25 @@ INSERT INTO users(name) VALUES
INSERT INTO bank_account(user_id, resource_id, balance) VALUES
(1, 1, 0),
(1, 1, 200),
(1, 2, 175),
(1, 3, 200),
(1, 3, 0),
(1, 4, 25),
(1, 5, 10);
INSERT INTO store_item(name, currency, target_resource, price, claim_amount) VALUES
('Drill 1A', 1, 1, 100, 500),
('Drill 1B', 2, 2, 100, 500),
('Drill 1C', 3, 3, 100, 500),
('Drill 1D', 4, 4, 100, 500),
('Drill 1E', 5, 5, 100, 500);
('Drill 1A', 1, 1, 25, 500),
('Drill 1B', 1, 2, 25, 500),
('Drill 1C', 1, 3, 25, 500),
('Drill 1D', 1, 4, 25, 500),
('Drill 1E', 1, 5, 25, 500);
SELECT staking_event.id,well_id,staking_event.source_id,
inventory_item_id,staking_event.created_at,expiration_at
FROM staking_event
INNER JOIN resource_well ON resource_well.id = well_id
INNER JOIN staking_source on staking_event.source_id = staking_source.id
WHERE staking_event.source_id = ? AND staking_source.user_id = ?;
SELECT name,init_supply
FROM resource_well

View File

@ -36,8 +36,8 @@ CREATE TABLE staking_event(
well_id int not null,
source_id int not null,
inventory_item_id int not null,
amount int not null,
created_at timestamp DEFAULT (current_timestamp),
expiration_at timestamp DEFAULT (current_timestamp),
CONSTRAINT fk_sid FOREIGN KEY(source_id)
REFERENCES staking_source(id)
CONSTRAINT fk_wid FOREIGN KEY(well_id)
@ -49,11 +49,10 @@ CREATE TABLE staking_event(
CREATE TABLE claim_event(
id integer primary key autoincrement,
resource_id int not null,
claim_type text CHECK ( claim_type IN ('BASE','BONUS') ),
claim_amount int not null,
created_at timestamp DEFAULT (current_timestamp),
CONSTRAINT fk_ures FOREIGN KEY(staking_source_id)
REFERENCES staking_source(id)
CONSTRAINT fk_rid FOREIGN KEY(resource_id)
REFERENCES resource(id)
);
CREATE TABLE upgrade_event(