diff --git a/db/migrations/00021_create_known_gaps_table.sql b/db/migrations/00021_create_known_gaps_table.sql index b6235b3..4a7c730 100644 --- a/db/migrations/00021_create_known_gaps_table.sql +++ b/db/migrations/00021_create_known_gaps_table.sql @@ -1,10 +1,10 @@ -- +goose Up -CREATE TABLE eth.known_gaps ( - starting_block_number bigint PRIMARY KEY, - ending_block_number bigint, - checked_out boolean, - processing_key bigint +CREATE TABLE eth_meta.known_gaps ( + starting_block_number bigint PRIMARY KEY, + ending_block_number bigint, + checked_out boolean, + processing_key bigint ); -- +goose Down -DROP TABLE eth.known_gaps; \ No newline at end of file +DROP TABLE eth_meta.known_gaps; diff --git a/db/post_batch_processing_migrations/00024_create_pk_constraints_part2.sql b/db/post_batch_processing_migrations/00023_create_pk_constraints.sql similarity index 62% rename from db/post_batch_processing_migrations/00024_create_pk_constraints_part2.sql rename to db/post_batch_processing_migrations/00023_create_pk_constraints.sql index ba40f0f..1c3e2cb 100644 --- a/db/post_batch_processing_migrations/00024_create_pk_constraints_part2.sql +++ b/db/post_batch_processing_migrations/00023_create_pk_constraints.sql @@ -1,4 +1,16 @@ -- +goose Up +ALTER TABLE public.nodes +ADD CONSTRAINT pk_public_nodes PRIMARY KEY (node_id); + +ALTER TABLE eth.header_cids +ADD CONSTRAINT pk_eth_header_cids PRIMARY KEY (block_hash); + +ALTER TABLE eth.uncle_cids +ADD CONSTRAINT pk_eth_uncle_cids PRIMARY KEY (block_hash); + +ALTER TABLE eth.transaction_cids +ADD CONSTRAINT pk_eth_transaction_cids PRIMARY KEY (tx_hash); + ALTER TABLE eth.receipt_cids ADD CONSTRAINT pk_eth_receipt_cids PRIMARY KEY (tx_id); @@ -35,3 +47,15 @@ DROP CONSTRAINT pk_eth_access_list_elements; ALTER TABLE eth.receipt_cids DROP CONSTRAINT pk_eth_receipt_cids; + +ALTER TABLE eth.transaction_cids +DROP CONSTRAINT pk_eth_transaction_cids; + +ALTER TABLE eth.uncle_cids +DROP CONSTRAINT pk_eth_uncle_cids; + +ALTER TABLE eth.header_cids +DROP CONSTRAINT pk_eth_header_cids; + +ALTER TABLE public.nodes +DROP CONSTRAINT pk_public_nodes; diff --git a/db/post_batch_processing_migrations/00023_create_pk_constraints_part1.sql b/db/post_batch_processing_migrations/00023_create_pk_constraints_part1.sql deleted file mode 100644 index 700d273..0000000 --- a/db/post_batch_processing_migrations/00023_create_pk_constraints_part1.sql +++ /dev/null @@ -1,25 +0,0 @@ --- +goose Up -ALTER TABLE public.nodes -ADD CONSTRAINT pk_public_nodes PRIMARY KEY (node_id); - -ALTER TABLE eth.header_cids -ADD CONSTRAINT pk_eth_header_cids PRIMARY KEY (block_hash); - -ALTER TABLE eth.uncle_cids -ADD CONSTRAINT pk_eth_uncle_cids PRIMARY KEY (block_hash); - -ALTER TABLE eth.transaction_cids -ADD CONSTRAINT pk_eth_transaction_cids PRIMARY KEY (tx_hash); - --- +goose Down -ALTER TABLE eth.transaction_cids -DROP CONSTRAINT pk_eth_transaction_cids; - -ALTER TABLE eth.uncle_cids -DROP CONSTRAINT pk_eth_uncle_cids; - -ALTER TABLE eth.header_cids -DROP CONSTRAINT pk_eth_header_cids; - -ALTER TABLE public.nodes -DROP CONSTRAINT pk_public_nodes; diff --git a/db/post_batch_processing_migrations/00024_create_eth_meta_schema.sql b/db/post_batch_processing_migrations/00024_create_eth_meta_schema.sql new file mode 100644 index 0000000..448cc91 --- /dev/null +++ b/db/post_batch_processing_migrations/00024_create_eth_meta_schema.sql @@ -0,0 +1,5 @@ +-- +goose Up +CREATE SCHEMA eth_meta; + +-- +goose Down +DROP SCHEMA eth_meta; diff --git a/db/post_batch_processing_migrations/00025_create_watched_addresses_table.sql b/db/post_batch_processing_migrations/00025_create_watched_addresses_table.sql new file mode 100644 index 0000000..a8f009f --- /dev/null +++ b/db/post_batch_processing_migrations/00025_create_watched_addresses_table.sql @@ -0,0 +1,10 @@ +-- +goose Up +CREATE TABLE eth_meta.watched_addresses ( + address VARCHAR(66) PRIMARY KEY, + created_at BIGINT NOT NULL, + watched_at BIGINT NOT NULL, + last_filled_at BIGINT NOT NULL DEFAULT 0 +); + +-- +goose Down +DROP TABLE eth_meta.watched_addresses; diff --git a/db/post_batch_processing_migrations/00026_create_known_gaps_table.sql b/db/post_batch_processing_migrations/00026_create_known_gaps_table.sql new file mode 100644 index 0000000..4f8032b --- /dev/null +++ b/db/post_batch_processing_migrations/00026_create_known_gaps_table.sql @@ -0,0 +1,10 @@ +-- +goose Up +CREATE TABLE eth_meta.known_gaps ( + starting_block_number bigint PRIMARY KEY, + ending_block_number bigint, + checked_out boolean, + processing_key bigint +); + +-- +goose Down +DROP TABLE eth_meta.known_gaps; diff --git a/db/post_batch_processing_migrations/00025_make_tables_logged.sql b/db/post_batch_processing_migrations/00027_make_tables_logged.sql similarity index 100% rename from db/post_batch_processing_migrations/00025_make_tables_logged.sql rename to db/post_batch_processing_migrations/00027_make_tables_logged.sql diff --git a/db/post_batch_processing_migrations/00026_create_fk_relations.sql b/db/post_batch_processing_migrations/00028_create_fk_relations.sql similarity index 100% rename from db/post_batch_processing_migrations/00026_create_fk_relations.sql rename to db/post_batch_processing_migrations/00028_create_fk_relations.sql diff --git a/db/post_batch_processing_migrations/00027_create_postgraphile_comments.sql b/db/post_batch_processing_migrations/00029_create_postgraphile_comments.sql similarity index 100% rename from db/post_batch_processing_migrations/00027_create_postgraphile_comments.sql rename to db/post_batch_processing_migrations/00029_create_postgraphile_comments.sql diff --git a/db/post_batch_processing_migrations/00028_create_cid_indexes.sql b/db/post_batch_processing_migrations/00030_create_cid_indexes.sql similarity index 100% rename from db/post_batch_processing_migrations/00028_create_cid_indexes.sql rename to db/post_batch_processing_migrations/00030_create_cid_indexes.sql diff --git a/db/post_batch_processing_migrations/00029_create_stored_functions.sql b/db/post_batch_processing_migrations/00031_create_stored_functions.sql similarity index 100% rename from db/post_batch_processing_migrations/00029_create_stored_functions.sql rename to db/post_batch_processing_migrations/00031_create_stored_functions.sql diff --git a/db/post_batch_processing_migrations/00030_create_postgraphile_triggers.sql b/db/post_batch_processing_migrations/00032_create_postgraphile_triggers.sql similarity index 100% rename from db/post_batch_processing_migrations/00030_create_postgraphile_triggers.sql rename to db/post_batch_processing_migrations/00032_create_postgraphile_triggers.sql diff --git a/schema.sql b/schema.sql index e588c8a..2e71a7d 100644 --- a/schema.sql +++ b/schema.sql @@ -409,6 +409,18 @@ CREATE TABLE eth.uncle_cids ( ); +-- +-- Name: known_gaps; Type: TABLE; Schema: eth_meta; Owner: - +-- + +CREATE TABLE eth_meta.known_gaps ( + starting_block_number bigint NOT NULL, + ending_block_number bigint, + checked_out boolean, + processing_key bigint +); + + -- -- Name: watched_addresses; Type: TABLE; Schema: eth_meta; Owner: - -- @@ -488,18 +500,6 @@ CREATE TABLE public.nodes ( ); --- --- Name: known_gaps; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE eth.known_gaps ( - starting_block_number bigint PRIMARY KEY, - ending_block_number bigint, - checked_out boolean, - processing_key bigint -); - - -- -- Name: TABLE nodes; Type: COMMENT; Schema: public; Owner: - -- @@ -593,6 +593,14 @@ ALTER TABLE ONLY eth.uncle_cids ADD CONSTRAINT uncle_cids_pkey PRIMARY KEY (block_hash); +-- +-- Name: known_gaps known_gaps_pkey; Type: CONSTRAINT; Schema: eth_meta; Owner: - +-- + +ALTER TABLE ONLY eth_meta.known_gaps + ADD CONSTRAINT known_gaps_pkey PRIMARY KEY (starting_block_number); + + -- -- Name: watched_addresses watched_addresses_pkey; Type: CONSTRAINT; Schema: eth_meta; Owner: - --