use state leaf key in storage_cids FK
This commit is contained in:
parent
b3832dd23d
commit
caf99f7194
@ -2,7 +2,7 @@
|
|||||||
CREATE TABLE IF NOT EXISTS eth.storage_cids (
|
CREATE TABLE IF NOT EXISTS eth.storage_cids (
|
||||||
block_number BIGINT NOT NULL,
|
block_number BIGINT NOT NULL,
|
||||||
header_id VARCHAR(66) NOT NULL,
|
header_id VARCHAR(66) NOT NULL,
|
||||||
state_path BYTEA NOT NULL,
|
state_leaf_key BYTEA NOT NULL,
|
||||||
storage_leaf_key VARCHAR(66),
|
storage_leaf_key VARCHAR(66),
|
||||||
cid TEXT NOT NULL,
|
cid TEXT NOT NULL,
|
||||||
storage_path BYTEA NOT NULL,
|
storage_path BYTEA NOT NULL,
|
||||||
@ -10,8 +10,8 @@ CREATE TABLE IF NOT EXISTS eth.storage_cids (
|
|||||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
mh_key TEXT NOT NULL,
|
mh_key TEXT NOT NULL,
|
||||||
FOREIGN KEY (mh_key, block_number) REFERENCES public.blocks (key, block_number) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
FOREIGN KEY (mh_key, block_number) REFERENCES public.blocks (key, block_number) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
FOREIGN KEY (state_path, header_id) REFERENCES eth.state_cids (state_path, header_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
FOREIGN KEY (state_leaf_key, header_id) REFERENCES eth.state_cids (state_leaf_key, header_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
PRIMARY KEY (storage_path, state_path, header_id)
|
PRIMARY KEY (storage_path, state_leaf_key, header_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
@ -36,7 +36,7 @@ CREATE INDEX state_node_type_index ON eth.state_cids USING btree (node_type);
|
|||||||
|
|
||||||
-- storage node indexes
|
-- storage node indexes
|
||||||
CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_number);
|
CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_number);
|
||||||
CREATE INDEX storage_state_path_index ON eth.storage_cids USING btree (state_path);
|
CREATE INDEX storage_state_leaf_key_index ON eth.storage_cids USING btree (state_leaf_key);
|
||||||
CREATE INDEX storage_leaf_key_index ON eth.storage_cids USING btree (storage_leaf_key);
|
CREATE INDEX storage_leaf_key_index ON eth.storage_cids USING btree (storage_leaf_key);
|
||||||
CREATE INDEX storage_cid_index ON eth.storage_cids USING btree (cid);
|
CREATE INDEX storage_cid_index ON eth.storage_cids USING btree (cid);
|
||||||
CREATE INDEX storage_mh_block_number_index ON eth.storage_cids USING btree (mh_key, block_number);
|
CREATE INDEX storage_mh_block_number_index ON eth.storage_cids USING btree (mh_key, block_number);
|
||||||
@ -90,7 +90,7 @@ DROP INDEX eth.storage_header_id_index;
|
|||||||
DROP INDEX eth.storage_mh_block_number_index;
|
DROP INDEX eth.storage_mh_block_number_index;
|
||||||
DROP INDEX eth.storage_cid_index;
|
DROP INDEX eth.storage_cid_index;
|
||||||
DROP INDEX eth.storage_leaf_key_index;
|
DROP INDEX eth.storage_leaf_key_index;
|
||||||
DROP INDEX eth.storage_state_path_index;
|
DROP INDEX eth.storage_state_leaf_key_index;
|
||||||
DROP INDEX eth.storage_block_number_index;
|
DROP INDEX eth.storage_block_number_index;
|
||||||
|
|
||||||
-- state node indexes
|
-- state node indexes
|
||||||
|
Loading…
Reference in New Issue
Block a user