Fix some SQL
This commit is contained in:
parent
852f134e47
commit
bdf58a624f
25
data.sql
25
data.sql
@ -1,9 +1,9 @@
|
|||||||
INSERT INTO resource(name) VALUES
|
INSERT INTO resource(name) VALUES
|
||||||
('NEBULANCE'),
|
('SOLLUX'),
|
||||||
('SHADOWSTONE'),
|
('SHADOWSTONE'),
|
||||||
('AZURIUM'),
|
('AZURIUM'),
|
||||||
('NOVAFOR'),
|
('NOVAFOR'),
|
||||||
('SOLLUX');
|
('NEBULANCE');
|
||||||
|
|
||||||
INSERT INTO users(name) VALUES
|
INSERT INTO users(name) VALUES
|
||||||
('Joe'),
|
('Joe'),
|
||||||
@ -14,20 +14,25 @@ INSERT INTO users(name) VALUES
|
|||||||
|
|
||||||
|
|
||||||
INSERT INTO bank_account(user_id, resource_id, balance) VALUES
|
INSERT INTO bank_account(user_id, resource_id, balance) VALUES
|
||||||
(1, 1, 0),
|
(1, 1, 200),
|
||||||
(1, 2, 175),
|
(1, 2, 175),
|
||||||
(1, 3, 200),
|
(1, 3, 0),
|
||||||
(1, 4, 25),
|
(1, 4, 25),
|
||||||
(1, 5, 10);
|
(1, 5, 10);
|
||||||
|
|
||||||
INSERT INTO store_item(name, currency, target_resource, price, claim_amount) VALUES
|
INSERT INTO store_item(name, currency, target_resource, price, claim_amount) VALUES
|
||||||
('Drill 1A', 1, 1, 100, 500),
|
('Drill 1A', 1, 1, 25, 500),
|
||||||
('Drill 1B', 2, 2, 100, 500),
|
('Drill 1B', 1, 2, 25, 500),
|
||||||
('Drill 1C', 3, 3, 100, 500),
|
('Drill 1C', 1, 3, 25, 500),
|
||||||
('Drill 1D', 4, 4, 100, 500),
|
('Drill 1D', 1, 4, 25, 500),
|
||||||
('Drill 1E', 5, 5, 100, 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
|
SELECT name,init_supply
|
||||||
FROM resource_well
|
FROM resource_well
|
||||||
|
@ -36,8 +36,8 @@ CREATE TABLE staking_event(
|
|||||||
well_id int not null,
|
well_id int not null,
|
||||||
source_id int not null,
|
source_id int not null,
|
||||||
inventory_item_id int not null,
|
inventory_item_id int not null,
|
||||||
amount int not null,
|
|
||||||
created_at timestamp DEFAULT (current_timestamp),
|
created_at timestamp DEFAULT (current_timestamp),
|
||||||
|
expiration_at timestamp DEFAULT (current_timestamp),
|
||||||
CONSTRAINT fk_sid FOREIGN KEY(source_id)
|
CONSTRAINT fk_sid FOREIGN KEY(source_id)
|
||||||
REFERENCES staking_source(id)
|
REFERENCES staking_source(id)
|
||||||
CONSTRAINT fk_wid FOREIGN KEY(well_id)
|
CONSTRAINT fk_wid FOREIGN KEY(well_id)
|
||||||
@ -49,11 +49,10 @@ CREATE TABLE staking_event(
|
|||||||
CREATE TABLE claim_event(
|
CREATE TABLE claim_event(
|
||||||
id integer primary key autoincrement,
|
id integer primary key autoincrement,
|
||||||
resource_id int not null,
|
resource_id int not null,
|
||||||
claim_type text CHECK ( claim_type IN ('BASE','BONUS') ),
|
|
||||||
claim_amount int not null,
|
claim_amount int not null,
|
||||||
created_at timestamp DEFAULT (current_timestamp),
|
created_at timestamp DEFAULT (current_timestamp),
|
||||||
CONSTRAINT fk_ures FOREIGN KEY(staking_source_id)
|
CONSTRAINT fk_rid FOREIGN KEY(resource_id)
|
||||||
REFERENCES staking_source(id)
|
REFERENCES resource(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE upgrade_event(
|
CREATE TABLE upgrade_event(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user