ipld-eth-server/db/migrations/00016_create_eth_log_cids_table.sql

62 lines
1.7 KiB
MySQL
Raw Normal View History

2021-08-12 06:23:41 +00:00
-- +goose Up
CREATE TABLE eth.log_cids (
2021-08-16 13:24:34 +00:00
id SERIAL PRIMARY KEY,
2021-08-20 07:37:11 +00:00
leaf_cid TEXT NOT NULL,
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
2021-08-16 13:24:34 +00:00
receipt_id INTEGER NOT NULL REFERENCES eth.receipt_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
2021-08-20 07:37:11 +00:00
address VARCHAR(66) NOT NULL,
2021-08-16 13:24:34 +00:00
log_data BYTEA,
index INTEGER NOT NULL,
topic0 VARCHAR(66),
topic1 VARCHAR(66),
topic2 VARCHAR(66),
topic3 VARCHAR(66),
2021-08-14 13:50:22 +00:00
UNIQUE (receipt_id, index)
2021-08-12 06:23:41 +00:00
);
2021-08-20 07:37:11 +00:00
CREATE INDEX log_mh_index ON eth.log_cids USING btree (leaf_mh_key);
2021-08-16 13:24:34 +00:00
2021-08-20 07:37:11 +00:00
CREATE INDEX log_cid_index ON eth.log_cids USING btree (leaf_cid);
2021-08-12 06:23:41 +00:00
2021-08-20 07:37:11 +00:00
CREATE INDEX log_rct_id_index ON eth.log_cids USING btree (receipt_id);
2021-08-12 06:23:41 +00:00
--
-- Name: log_topic0_index; Type: INDEX; Schema: eth; Owner: -
--
2021-08-14 13:50:22 +00:00
CREATE INDEX log_topic0_index ON eth.log_cids USING btree (topic0);
2021-08-12 06:23:41 +00:00
--
-- Name: log_topic1_index; Type: INDEX; Schema: eth; Owner: -
--
2021-08-14 13:50:22 +00:00
CREATE INDEX log_topic1_index ON eth.log_cids USING btree (topic1);
2021-08-12 06:23:41 +00:00
--
-- Name: log_topic2_index; Type: INDEX; Schema: eth; Owner: -
--
2021-08-14 13:50:22 +00:00
CREATE INDEX log_topic2_index ON eth.log_cids USING btree (topic2);
2021-08-12 06:23:41 +00:00
--
-- Name: log_topic3_index; Type: INDEX; Schema: eth; Owner: -
--
2021-08-14 13:50:22 +00:00
CREATE INDEX log_topic3_index ON eth.log_cids USING btree (topic3);
2021-08-12 06:23:41 +00:00
-- +goose Down
2021-08-20 07:37:11 +00:00
-- log indexes
DROP INDEX eth.log_mh_index;
DROP INDEX eth.log_cid_index;
DROP INDEX eth.log_rct_id_index;
DROP INDEX eth.log_topic0_index;
DROP INDEX eth.log_topic1_index;
DROP INDEX eth.log_topic2_index;
DROP INDEX eth.log_topic3_index;
DROP TABLE eth.log_cids;