Skip to content

Commit

Permalink
add transfers table indexed by block_num
Browse files Browse the repository at this point in the history
  • Loading branch information
fschoell committed Apr 10, 2024
1 parent db8d2e1 commit 881e9ea
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ CREATE TABLE IF NOT EXISTS transfers_from
block_num UInt64,
timestamp DateTime
)
ENGINE = ReplacingMergeTree(block_num)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (from, to, trx_id, action_index)
ORDER BY (from, to, trx_id, action_index);

Expand All @@ -257,10 +257,35 @@ CREATE TABLE IF NOT EXISTS transfers_to
block_num UInt64,
timestamp DateTime
)
ENGINE = ReplacingMergeTree(block_num)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (to, from, trx_id, action_index)
ORDER BY (to, from, trx_id, action_index);

-- Table to store token transfers primarily indexed by the 'block_num' field
CREATE TABLE IF NOT EXISTS transfers_block_num
(
trx_id String,
action_index UInt32,

contract String,
symcode String,

from String,
to String,
quantity String,
memo String,

precision UInt32,
amount Int64,
value Float64,

block_num UInt64,
timestamp DateTime
)
ENGINE = ReplacingMergeTree()
PRIMARY KEY (block_num, trx_id, action_index)
ORDER BY (block_num, trx_id, action_index);

---------------------------------------------------------
-- Materialized views to populate the extracted tables --
---------------------------------------------------------
Expand Down Expand Up @@ -315,6 +340,24 @@ FROM transfer_events;
CREATE MATERIALIZED VIEW transfers_to_mv
TO transfers_to
AS
SELECT trx_id,
action_index,
contract,
symcode,
from,
to,
quantity,
memo,
precision,
amount,
value,
block_num,
timestamp
FROM transfer_events;

CREATE MATERIALIZED VIEW transfers_block_num_mv
TO transfers_block_num
AS
SELECT trx_id,
action_index,
contract,
Expand Down

0 comments on commit 881e9ea

Please sign in to comment.