diff --git a/db/migrations/00028_create_header_cids_table.sql b/db/migrations/00028_create_header_cids_table.sql new file mode 100644 index 00000000..e282fe01 --- /dev/null +++ b/db/migrations/00028_create_header_cids_table.sql @@ -0,0 +1,11 @@ +-- +goose Up +CREATE TABLE public.header_cids ( + id SERIAL PRIMARY KEY, + block_number BIGINT NOT NULL, + block_hash VARCHAR(66) NOT NULL, + cid TEXT NOT NULL, + UNIQUE (block_number, block_hash) +); + +-- +goose Down +DROP TABLE public.header_cids; \ No newline at end of file diff --git a/db/migrations/00029_create_transaction_cids_table.sql b/db/migrations/00029_create_transaction_cids_table.sql new file mode 100644 index 00000000..a7dd0f11 --- /dev/null +++ b/db/migrations/00029_create_transaction_cids_table.sql @@ -0,0 +1,11 @@ +-- +goose Up +CREATE TABLE public.transaction_cids ( + id SERIAL PRIMARY KEY, + header_id INTEGER NOT NULL REFERENCES header_cids (id) ON DELETE CASCADE, + tx_hash VARCHAR(66) NOT NULL, + cid TEXT NOT NULL, + UNIQUE (header_id, tx_hash) +); + +-- +goose Down +DROP TABLE public.transaction_cids; diff --git a/db/migrations/00030_create_receipt_cids_table.sql b/db/migrations/00030_create_receipt_cids_table.sql new file mode 100644 index 00000000..5a167b46 --- /dev/null +++ b/db/migrations/00030_create_receipt_cids_table.sql @@ -0,0 +1,9 @@ +-- +goose Up +CREATE TABLE public.receipt_cids ( + id SERIAL PRIMARY KEY, + tx_id INTEGER NOT NULL REFERENCES transaction_cids (id) ON DELETE CASCADE, + cid TEXT NOT NULL +); + +-- +goose Down +DROP TABLE public.receipt_cids; \ No newline at end of file diff --git a/db/migrations/00031_create_state_cids_table.sql b/db/migrations/00031_create_state_cids_table.sql new file mode 100644 index 00000000..e7b9e48f --- /dev/null +++ b/db/migrations/00031_create_state_cids_table.sql @@ -0,0 +1,11 @@ +-- +goose Up +CREATE TABLE public.state_cids ( + id SERIAL PRIMARY KEY, + header_id INTEGER NOT NULL REFERENCES header_cids (id) ON DELETE CASCADE, + account_key VARCHAR(66) NOT NULL, + cid TEXT NOT NULL, + UNIQUE (header_id, account_key) +); + +-- +goose Down +DROP TABLE public.state_cids; \ No newline at end of file diff --git a/db/migrations/00032_create_storage_cids_table.sql b/db/migrations/00032_create_storage_cids_table.sql new file mode 100644 index 00000000..319fd0ec --- /dev/null +++ b/db/migrations/00032_create_storage_cids_table.sql @@ -0,0 +1,11 @@ +-- +goose Up +CREATE TABLE public.storage_cids ( + id SERIAL PRIMARY KEY, + state_id INTEGER NOT NULL REFERENCES state_cids (id) ON DELETE CASCADE, + storage_key VARCHAR(66) NOT NULL, + cid TEXT NOT NULL, + UNIQUE (state_id, storage_key) +); + +-- +goose Down +DROP TABLE public.storage_cids; \ No newline at end of file