cid database table migrations

This commit is contained in:
Ian Norden 2019-04-15 11:30:41 -05:00
parent 1921c06b02
commit e033eabc28
5 changed files with 53 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;