public.blocks => ipld.blocks
This commit is contained in:
parent
c402e5c285
commit
a8440e4ded
@ -1,10 +1,13 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS public.blocks (
|
CREATE SCHEMA ipld;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS ipld.blocks (
|
||||||
block_number BIGINT NOT NULL,
|
block_number BIGINT NOT NULL,
|
||||||
cid TEXT NOT NULL,
|
key TEXT NOT NULL,
|
||||||
data BYTEA NOT NULL,
|
data BYTEA NOT NULL,
|
||||||
PRIMARY KEY (key, block_number)
|
PRIMARY KEY (key, block_number)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE public.blocks;
|
DROP TABLE ipld.blocks;
|
||||||
|
DROP SCHEMA ipld;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
-- pending tx isn't tightly associated with a block height, so we can't insert the RLP encoded tx as an IPLD block
|
-- pending tx isn't tightly associated with a block height, so we can't insert the RLP encoded tx as an IPLD block
|
||||||
-- in public.blocks since it is denormalized by block number (we could do something hacky like using head height
|
-- in ipld.blocks since it is denormalized by block number (we could do something hacky like using head height
|
||||||
-- when the block was seen, or 0 or -1 or something)
|
-- when the block was seen, or 0 or -1 or something)
|
||||||
-- instead, what we are doing for the time being is embedding the RLP here
|
-- instead, what we are doing for the time being is embedding the RLP here
|
||||||
CREATE TABLE IF NOT EXISTS eth.pending_txs (
|
CREATE TABLE IF NOT EXISTS eth.pending_txs (
|
||||||
|
@ -28,7 +28,7 @@ CREATE INDEX rct_contract_hash_index ON eth.receipt_cids USING btree (contract_h
|
|||||||
CREATE INDEX state_block_number_index ON eth.state_cids USING brin (block_number);
|
CREATE INDEX state_block_number_index ON eth.state_cids USING brin (block_number);
|
||||||
CREATE INDEX state_cid_block_number_index ON eth.state_cids USING btree (cid, block_number);
|
CREATE INDEX state_cid_block_number_index ON eth.state_cids USING btree (cid, block_number);
|
||||||
CREATE INDEX state_header_id_index ON eth.state_cids USING btree (header_id);
|
CREATE INDEX state_header_id_index ON eth.state_cids USING btree (header_id);
|
||||||
CREATE INDEX state_path_index ON eth.state_cids USING btree (state_path);
|
CREATE INDEX state_partial_path_index ON eth.state_cids USING btree (partial_path);
|
||||||
CREATE INDEX state_removed_index ON eth.state_cids USING btree (removed);
|
CREATE INDEX state_removed_index ON eth.state_cids USING btree (removed);
|
||||||
CREATE INDEX state_code_hash_index ON eth.state_cids USING btree (code_hash); -- could be useful for e.g. selecting all the state accounts with the same contract bytecode deployed
|
CREATE INDEX state_code_hash_index ON eth.state_cids USING btree (code_hash); -- could be useful for e.g. selecting all the state accounts with the same contract bytecode deployed
|
||||||
CREATE INDEX state_leaf_key_block_number_index ON eth.state_cids(state_leaf_key, block_number DESC);
|
CREATE INDEX state_leaf_key_block_number_index ON eth.state_cids(state_leaf_key, block_number DESC);
|
||||||
@ -38,7 +38,7 @@ CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_nu
|
|||||||
CREATE INDEX storage_state_leaf_key_index ON eth.storage_cids USING btree (state_leaf_key);
|
CREATE INDEX storage_state_leaf_key_index ON eth.storage_cids USING btree (state_leaf_key);
|
||||||
CREATE INDEX storage_cid_block_number_index ON eth.storage_cids USING btree (cid, block_number);
|
CREATE INDEX storage_cid_block_number_index ON eth.storage_cids USING btree (cid, block_number);
|
||||||
CREATE INDEX storage_header_id_index ON eth.storage_cids USING btree (header_id);
|
CREATE INDEX storage_header_id_index ON eth.storage_cids USING btree (header_id);
|
||||||
CREATE INDEX storage_path_index ON eth.storage_cids USING btree (storage_path);
|
CREATE INDEX storage_partial_path_index ON eth.storage_cids USING btree (partial_path);
|
||||||
CREATE INDEX storage_removed_index ON eth.storage_cids USING btree (removed);
|
CREATE INDEX storage_removed_index ON eth.storage_cids USING btree (removed);
|
||||||
CREATE INDEX storage_leaf_key_block_number_index ON eth.storage_cids(storage_leaf_key, block_number DESC);
|
CREATE INDEX storage_leaf_key_block_number_index ON eth.storage_cids(storage_leaf_key, block_number DESC);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ DROP INDEX eth.access_list_block_number_index;
|
|||||||
|
|
||||||
-- storage node indexes
|
-- storage node indexes
|
||||||
DROP INDEX eth.storage_removed_index;
|
DROP INDEX eth.storage_removed_index;
|
||||||
DROP INDEX eth.storage_path_index;
|
DROP INDEX eth.storage_partial_path_index;
|
||||||
DROP INDEX eth.storage_header_id_index;
|
DROP INDEX eth.storage_header_id_index;
|
||||||
DROP INDEX eth.storage_cid_block_number_index;
|
DROP INDEX eth.storage_cid_block_number_index;
|
||||||
DROP INDEX eth.storage_leaf_key_index;
|
DROP INDEX eth.storage_leaf_key_index;
|
||||||
@ -86,7 +86,7 @@ DROP INDEX eth.storage_leaf_key_block_number_index;
|
|||||||
-- state node indexes
|
-- state node indexes
|
||||||
DROP INDEX eth.state_code_hash_index;
|
DROP INDEX eth.state_code_hash_index;
|
||||||
DROP INDEX eth.state_removed_index;
|
DROP INDEX eth.state_removed_index;
|
||||||
DROP INDEX eth.state_path_index;
|
DROP INDEX eth.state_partial_path_index;
|
||||||
DROP INDEX eth.state_header_id_index;
|
DROP INDEX eth.state_header_id_index;
|
||||||
DROP INDEX eth.state_cid_block_number_index;
|
DROP INDEX eth.state_cid_block_number_index;
|
||||||
DROP INDEX eth.state_block_number_index;
|
DROP INDEX eth.state_block_number_index;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
SELECT create_hypertable('public.blocks', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
SELECT create_hypertable('ipld.blocks', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||||
SELECT create_hypertable('eth.header_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
SELECT create_hypertable('eth.header_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||||
SELECT create_hypertable('eth.uncle_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
SELECT create_hypertable('eth.uncle_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||||
SELECT create_hypertable('eth.transaction_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
SELECT create_hypertable('eth.transaction_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||||
@ -27,7 +27,7 @@ CREATE TABLE eth.receipt_cids_i (LIKE eth.receipt_cids INCLUDING ALL);
|
|||||||
CREATE TABLE eth.transaction_cids_i (LIKE eth.transaction_cids INCLUDING ALL);
|
CREATE TABLE eth.transaction_cids_i (LIKE eth.transaction_cids INCLUDING ALL);
|
||||||
CREATE TABLE eth.uncle_cids_i (LIKE eth.uncle_cids INCLUDING ALL);
|
CREATE TABLE eth.uncle_cids_i (LIKE eth.uncle_cids INCLUDING ALL);
|
||||||
CREATE TABLE eth.header_cids_i (LIKE eth.header_cids INCLUDING ALL);
|
CREATE TABLE eth.header_cids_i (LIKE eth.header_cids INCLUDING ALL);
|
||||||
CREATE TABLE public.blocks_i (LIKE public.blocks INCLUDING ALL);
|
CREATE TABLE ipld.blocks_i (LIKE ipld.blocks INCLUDING ALL);
|
||||||
|
|
||||||
-- migrate data
|
-- migrate data
|
||||||
INSERT INTO eth.log_cids_i (SELECT * FROM eth.log_cids);
|
INSERT INTO eth.log_cids_i (SELECT * FROM eth.log_cids);
|
||||||
@ -38,7 +38,7 @@ INSERT INTO eth.receipt_cids_i (SELECT * FROM eth.receipt_cids);
|
|||||||
INSERT INTO eth.transaction_cids_i (SELECT * FROM eth.transaction_cids);
|
INSERT INTO eth.transaction_cids_i (SELECT * FROM eth.transaction_cids);
|
||||||
INSERT INTO eth.uncle_cids_i (SELECT * FROM eth.uncle_cids);
|
INSERT INTO eth.uncle_cids_i (SELECT * FROM eth.uncle_cids);
|
||||||
INSERT INTO eth.header_cids_i (SELECT * FROM eth.header_cids);
|
INSERT INTO eth.header_cids_i (SELECT * FROM eth.header_cids);
|
||||||
INSERT INTO public.blocks_i (SELECT * FROM public.blocks);
|
INSERT INTO ipld.blocks_i (SELECT * FROM ipld.blocks);
|
||||||
|
|
||||||
-- drop hypertables
|
-- drop hypertables
|
||||||
DROP TABLE eth.log_cids;
|
DROP TABLE eth.log_cids;
|
||||||
@ -49,7 +49,7 @@ DROP TABLE eth.receipt_cids;
|
|||||||
DROP TABLE eth.transaction_cids;
|
DROP TABLE eth.transaction_cids;
|
||||||
DROP TABLE eth.uncle_cids;
|
DROP TABLE eth.uncle_cids;
|
||||||
DROP TABLE eth.header_cids;
|
DROP TABLE eth.header_cids;
|
||||||
DROP TABLE public.blocks;
|
DROP TABLE ipld.blocks;
|
||||||
|
|
||||||
-- rename new tables
|
-- rename new tables
|
||||||
ALTER TABLE eth.log_cids_i RENAME TO log_cids;
|
ALTER TABLE eth.log_cids_i RENAME TO log_cids;
|
||||||
@ -60,4 +60,4 @@ ALTER TABLE eth.receipt_cids_i RENAME TO receipt_cids;
|
|||||||
ALTER TABLE eth.transaction_cids_i RENAME TO transaction_cids;
|
ALTER TABLE eth.transaction_cids_i RENAME TO transaction_cids;
|
||||||
ALTER TABLE eth.uncle_cids_i RENAME TO uncle_cids;
|
ALTER TABLE eth.uncle_cids_i RENAME TO uncle_cids;
|
||||||
ALTER TABLE eth.header_cids_i RENAME TO header_cids;
|
ALTER TABLE eth.header_cids_i RENAME TO header_cids;
|
||||||
ALTER TABLE public.blocks_i RENAME TO blocks;
|
ALTER TABLE ipld.blocks_i RENAME TO blocks;
|
||||||
|
Loading…
Reference in New Issue
Block a user