set of migrations for the parallel batch processing

This commit is contained in:
i-norden 2021-11-15 11:08:56 -06:00
parent 68e2b1e5cd
commit 8e644ebdf4
12 changed files with 155 additions and 0 deletions

View File

@ -0,0 +1,8 @@
-- +goose Up
CREATE TABLE IF NOT EXISTS public.blocks (
key TEXT PRIMARY KEY,
data BYTEA NOT NULL
);
-- +goose Down
DROP TABLE public.blocks;

View File

@ -0,0 +1,13 @@
-- +goose Up
CREATE TABLE nodes (
id SERIAL PRIMARY KEY,
client_name VARCHAR,
genesis_block VARCHAR(66),
network_id VARCHAR,
node_id VARCHAR(128),
chain_id INTEGER DEFAULT 1,
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id)
);
-- +goose Down
DROP TABLE nodes;

View File

@ -0,0 +1,5 @@
-- +goose Up
CREATE SCHEMA eth;
-- +goose Down
DROP SCHEMA eth;

View File

@ -0,0 +1,22 @@
-- +goose Up
CREATE TABLE eth.header_cids (
block_hash VARCHAR(66) NOT NULL,
block_number BIGINT NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL,
td NUMERIC NOT NULL,
node_id INTEGER NOT NULL REFERENCES nodes (id) ON DELETE CASCADE,
reward NUMERIC NOT NULL,
state_root VARCHAR(66) NOT NULL,
tx_root VARCHAR(66) NOT NULL,
receipt_root VARCHAR(66) NOT NULL,
uncle_root VARCHAR(66) NOT NULL,
bloom BYTEA NOT NULL,
timestamp NUMERIC NOT NULL,
times_validated INTEGER NOT NULL DEFAULT 1,
base_fee BIGINT
);
-- +goose Down
DROP TABLE eth.header_cids;

View File

@ -0,0 +1,12 @@
-- +goose Up
CREATE TABLE eth.uncle_cids (
block_hash VARCHAR(66) NOT NULL,
header_id VARCHAR(66) NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL,
reward NUMERIC NOT NULL
);
-- +goose Down
DROP TABLE eth.uncle_cids;

View File

@ -0,0 +1,15 @@
-- +goose Up
CREATE TABLE eth.transaction_cids (
tx_hash VARCHAR(66) NOT NULL,
header_id VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL,
dst VARCHAR(66) NOT NULL,
src VARCHAR(66) NOT NULL,
tx_data BYTEA,
tx_type INTEGER
);
-- +goose Down
DROP TABLE eth.transaction_cids;

View File

@ -0,0 +1,14 @@
-- +goose Up
CREATE TABLE eth.receipt_cids (
tx_id VARCHAR(66) NOT NULL,
leaf_cid TEXT NOT NULL,
leaf_mh_key TEXT NOT NULL,
contract VARCHAR(66),
contract_hash VARCHAR(66),
post_state VARCHAR(66),
post_status INTEGER,
log_root VARCHAR(66)
);
-- +goose Down
DROP TABLE eth.receipt_cids;

View File

@ -0,0 +1,13 @@
-- +goose Up
CREATE TABLE eth.state_cids (
header_id VARCHAR(66) NOT NULL,
state_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
mh_key TEXT NOT NULL,
state_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE
);
-- +goose Down
DROP TABLE eth.state_cids;

View File

@ -0,0 +1,14 @@
-- +goose Up
CREATE TABLE eth.storage_cids (
header_id VARCHAR(66) NOT NULL,
state_path BYTEA NOT NULL,
storage_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
mh_key TEXT NOT NULL,
storage_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE
);
-- +goose Down
DROP TABLE eth.storage_cids;

View File

@ -0,0 +1,12 @@
-- +goose Up
CREATE TABLE eth.state_accounts (
header_id VARCHAR(66) NOT NULL,
state_path BYTEA NOT NULL,
balance NUMERIC NOT NULL,
nonce INTEGER NOT NULL,
code_hash BYTEA NOT NULL,
storage_root VARCHAR(66) NOT NULL
);
-- +goose Down
DROP TABLE eth.state_accounts;

View File

@ -0,0 +1,10 @@
-- +goose Up
CREATE TABLE eth.access_list_element (
tx_id VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
address VARCHAR(66),
storage_keys VARCHAR(66)[]
);
-- +goose Down
DROP TABLE eth.access_list_element;

View File

@ -0,0 +1,17 @@
-- +goose Up
CREATE TABLE eth.log_cids (
rct_id VARCHAR(66) NOT NULL,
leaf_cid TEXT NOT NULL,
leaf_mh_key TEXT NOT NULL,
address VARCHAR(66) NOT NULL,
log_data BYTEA,
index INTEGER NOT NULL,
topic0 VARCHAR(66),
topic1 VARCHAR(66),
topic2 VARCHAR(66),
topic3 VARCHAR(66)
);
-- +goose Down
-- log indexes
DROP TABLE eth.log_cids;