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
INNER JOIN resource ON resource.id = resource_well.resource_id
WHERE source_id = 1;

SELECT inventory_item.id,store_item_id, COUNT(upgrade_event.id) as upgrades
FROM inventory_item
LEFT JOIN upgrade_event ON inventory_item.id = upgrade_event.inventory_item_id
WHERE inventory_item.user_id = 1
GROUP BY inventory_item.id;

SELECT inventory_item.id,store_item_id
FROM inventory_item;

SELECT staking_event.id,well_id,staking_event.source_id,
    inventory_item_id,staking_event.created_at,expiration_at
FROM staking_event
INNER JOIN staking_source on staking_event.source_id = staking_source.id
WHERE staking_event.source_id = 4 AND staking_source.user_id = 1;

SELECT staking_event.id, staking_event.well_id, staking_event.source_id,
    staking_event.inventory_item_id, staking_event.duration_in_mins,
    staking_event.created_at
FROM staking_event
LEFT JOIN claim_event ON staking_event.id = claim_event.staking_event_id
WHERE staking_event.source_id = 4 AND claim_event.staking_event_id IS NULL;

update staking_event  set created_at = '2023-02-21 12:58:02';
