Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fees typecast to bigint via migration, and fixes rollback migrati…
…ons to properly restore
- Loading branch information
Showing
6 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
packages/api-cardano-db-hasura/hasura/project/migrations/1589369664961_init/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
DROP VIEW IF EXISTS "Block", "Cardano", "Epoch", "Transaction", "Utxo", "TransactionInput", "TransactionOutput" CASCADE; | ||
DROP FUNCTION IF EXISTS utxo_set_at_block CASCADE; | ||
drop view if exists "Block", "Cardano", "Epoch", "Transaction", "Utxo", "TransactionInput", "TransactionOutput" cascade; | ||
drop function if exists utxo_set_at_block cascade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...no-db-hasura/hasura/project/migrations/1590383124093_add_transaction_block_index/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
DROP VIEW IF EXISTS "Transaction" CASCADE; | ||
drop view if exists "Transaction" cascade; | ||
create view "Transaction" as | ||
select | ||
block.hash as "blockHash", | ||
coalesce(tx.fee, 0) as fee, | ||
tx.hash as hash, | ||
cast((select sum("value") from tx_out where tx_id = tx.id) as bigint) as "totalOutput", | ||
tx.size, | ||
block.time as "includedAt" | ||
from | ||
tx | ||
inner join block | ||
on block.id = tx.block; |
5 changes: 3 additions & 2 deletions
5
...dano-db-hasura/hasura/project/migrations/1590383124093_add_transaction_block_index/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...-cardano-db-hasura/hasura/project/migrations/1593691353254_block_fees_to_big_int/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
drop view if exists "Block" cascade; | ||
create view "Block" as | ||
select | ||
cast(coalesce((select sum(tx.fee) from tx where tx.block = block.id), 0) as integer) as "fees", | ||
block.hash as hash, | ||
block.merkel_root as "merkelRoot", | ||
block.block_no as number, | ||
previous_block."hash" as "previousBlockHash", | ||
next_block."hash" as "nextBlockHash", | ||
slot_leader."description" as "createdBy", | ||
block.size as size, | ||
block.tx_count as "transactionsCount", | ||
block.epoch_no as "epochNo", | ||
block.slot_no as "slotNo", | ||
block.slot_no - (block.epoch_no * (10 * (select protocol_const from meta))) as "slotWithinEpoch", | ||
block.time as "createdAt" | ||
from block | ||
left outer join block as previous_block | ||
on block.previous = previous_block.id | ||
left outer join block as next_block | ||
on next_block.previous = block.id | ||
left outer join slot_leader | ||
on block.slot_leader = slot_leader.id; |
36 changes: 36 additions & 0 deletions
36
...pi-cardano-db-hasura/hasura/project/migrations/1593691353254_block_fees_to_big_int/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
drop view "Block" cascade; | ||
create view "Block" as | ||
select | ||
cast(coalesce((select sum(tx.fee) from tx where tx.block = block.id), 0) as bigint) as "fees", | ||
block.hash as hash, | ||
block.merkel_root as "merkelRoot", | ||
block.block_no as number, | ||
previous_block."hash" as "previousBlockHash", | ||
next_block."hash" as "nextBlockHash", | ||
slot_leader."description" as "createdBy", | ||
block.size as size, | ||
block.tx_count as "transactionsCount", | ||
block.epoch_no as "epochNo", | ||
block.slot_no as "slotNo", | ||
block.slot_no - (block.epoch_no * (10 * (select protocol_const from meta))) as "slotWithinEpoch", | ||
block.time as "createdAt" | ||
from block | ||
left outer join block as previous_block | ||
on block.previous = previous_block.id | ||
left outer join block as next_block | ||
on next_block.previous = block.id | ||
left outer join slot_leader | ||
on block.slot_leader = slot_leader.id; | ||
|
||
create view "Cardano" as | ||
select | ||
number as "blockHeight", | ||
"epochNo" as "currentEpochNo", | ||
(select slot_duration from meta) as "slotDuration", | ||
(select start_time from meta) as "startTime", | ||
(select protocol_const from meta) as "protocolConst", | ||
(select network_name from meta) as "networkName" | ||
from "Block" | ||
where number is not null | ||
order by number desc | ||
limit 1; |