forked from cerc-io/ipld-eth-server
update migrations and schema
This commit is contained in:
parent
1dee766014
commit
9758770579
@ -6,7 +6,7 @@ CREATE TABLE eth.state_cids (
|
||||
cid TEXT NOT NULL,
|
||||
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
state_path BYTEA,
|
||||
node_type INTEGER,
|
||||
node_type INTEGER NOT NULL,
|
||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
UNIQUE (header_id, state_path)
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE eth.state_accounts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
state_id INTEGER NOT NULL REFERENCES eth.state_cids (id) ON DELETE CASCADE,
|
||||
state_id INTEGER NOT NULL REFERENCES eth.state_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
balance NUMERIC NOT NULL,
|
||||
nonce INTEGER NOT NULL,
|
||||
code_hash BYTEA NOT NULL,
|
||||
|
@ -1,9 +1,6 @@
|
||||
-- +goose Up
|
||||
COMMENT ON TABLE public.nodes IS E'@name NodeInfo';
|
||||
COMMENT ON TABLE btc.header_cids IS E'@name BtcHeaderCids';
|
||||
COMMENT ON TABLE btc.transaction_cids IS E'@name BtcTransactionCids';
|
||||
COMMENT ON TABLE eth.transaction_cids IS E'@name EthTransactionCids';
|
||||
COMMENT ON TABLE eth.header_cids IS E'@name EthHeaderCids';
|
||||
COMMENT ON COLUMN public.nodes.node_id IS E'@name ChainNodeID';
|
||||
COMMENT ON COLUMN eth.header_cids.node_id IS E'@name EthNodeID';
|
||||
COMMENT ON COLUMN btc.header_cids.node_id IS E'@name BtcNodeID';
|
317
db/schema.sql
317
db/schema.sql
@ -16,13 +16,6 @@ SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- Name: btc; Type: SCHEMA; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
CREATE SCHEMA btc;
|
||||
|
||||
|
||||
--
|
||||
-- Name: eth; Type: SCHEMA; Schema: -; Owner: -
|
||||
--
|
||||
@ -34,172 +27,6 @@ SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: header_cids; Type: TABLE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE btc.header_cids (
|
||||
id integer NOT NULL,
|
||||
block_number bigint NOT NULL,
|
||||
block_hash character varying(66) NOT NULL,
|
||||
parent_hash character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
"timestamp" numeric NOT NULL,
|
||||
bits bigint NOT NULL,
|
||||
node_id integer NOT NULL,
|
||||
times_validated integer DEFAULT 1 NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TABLE header_cids; Type: COMMENT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON TABLE btc.header_cids IS '@name BtcHeaderCids';
|
||||
|
||||
|
||||
--
|
||||
-- Name: COLUMN header_cids.node_id; Type: COMMENT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON COLUMN btc.header_cids.node_id IS '@name BtcNodeID';
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids_id_seq; Type: SEQUENCE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE btc.header_cids_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE btc.header_cids_id_seq OWNED BY btc.header_cids.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids; Type: TABLE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE btc.transaction_cids (
|
||||
id integer NOT NULL,
|
||||
header_id integer NOT NULL,
|
||||
index integer NOT NULL,
|
||||
tx_hash character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
segwit boolean NOT NULL,
|
||||
witness_hash character varying(66)
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TABLE transaction_cids; Type: COMMENT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON TABLE btc.transaction_cids IS '@name BtcTransactionCids';
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids_id_seq; Type: SEQUENCE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE btc.transaction_cids_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE btc.transaction_cids_id_seq OWNED BY btc.transaction_cids.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs; Type: TABLE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE btc.tx_inputs (
|
||||
id integer NOT NULL,
|
||||
tx_id integer NOT NULL,
|
||||
index integer NOT NULL,
|
||||
witness character varying[],
|
||||
sig_script bytea NOT NULL,
|
||||
outpoint_tx_hash character varying(66) NOT NULL,
|
||||
outpoint_index numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs_id_seq; Type: SEQUENCE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE btc.tx_inputs_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE btc.tx_inputs_id_seq OWNED BY btc.tx_inputs.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs; Type: TABLE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE btc.tx_outputs (
|
||||
id integer NOT NULL,
|
||||
tx_id integer NOT NULL,
|
||||
index integer NOT NULL,
|
||||
value bigint NOT NULL,
|
||||
pk_script bytea NOT NULL,
|
||||
script_class integer NOT NULL,
|
||||
addresses character varying(66)[],
|
||||
required_sigs integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs_id_seq; Type: SEQUENCE; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE btc.tx_outputs_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs_id_seq; Type: SEQUENCE OWNED BY; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE btc.tx_outputs_id_seq OWNED BY btc.tx_outputs.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids; Type: TABLE; Schema: eth; Owner: -
|
||||
--
|
||||
@ -342,7 +169,7 @@ CREATE TABLE eth.state_cids (
|
||||
cid text NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
state_path bytea,
|
||||
node_type integer,
|
||||
node_type integer NOT NULL,
|
||||
diff boolean DEFAULT false NOT NULL
|
||||
);
|
||||
|
||||
@ -572,34 +399,6 @@ CREATE SEQUENCE public.nodes_id_seq
|
||||
ALTER SEQUENCE public.nodes_id_seq OWNED BY public.nodes.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids id; Type: DEFAULT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.header_cids ALTER COLUMN id SET DEFAULT nextval('btc.header_cids_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids id; Type: DEFAULT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids ALTER COLUMN id SET DEFAULT nextval('btc.transaction_cids_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs id; Type: DEFAULT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs ALTER COLUMN id SET DEFAULT nextval('btc.tx_inputs_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs id; Type: DEFAULT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_outputs ALTER COLUMN id SET DEFAULT nextval('btc.tx_outputs_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids id; Type: DEFAULT; Schema: eth; Owner: -
|
||||
--
|
||||
@ -663,70 +462,6 @@ ALTER TABLE ONLY public.goose_db_version ALTER COLUMN id SET DEFAULT nextval('pu
|
||||
ALTER TABLE ONLY public.nodes ALTER COLUMN id SET DEFAULT nextval('public.nodes_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_block_number_block_hash_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.header_cids
|
||||
ADD CONSTRAINT header_cids_block_number_block_hash_key UNIQUE (block_number, block_hash);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.header_cids
|
||||
ADD CONSTRAINT header_cids_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_tx_hash_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_tx_hash_key UNIQUE (tx_hash);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs
|
||||
ADD CONSTRAINT tx_inputs_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_tx_id_index_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs
|
||||
ADD CONSTRAINT tx_inputs_tx_id_index_key UNIQUE (tx_id, index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs tx_outputs_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_outputs
|
||||
ADD CONSTRAINT tx_outputs_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs tx_outputs_tx_id_index_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_outputs
|
||||
ADD CONSTRAINT tx_outputs_tx_id_index_key UNIQUE (tx_id, index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_block_number_block_hash_key; Type: CONSTRAINT; Schema: eth; Owner: -
|
||||
--
|
||||
@ -871,54 +606,6 @@ ALTER TABLE ONLY public.nodes
|
||||
ADD CONSTRAINT nodes_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_mh_key_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.header_cids
|
||||
ADD CONSTRAINT header_cids_mh_key_fkey FOREIGN KEY (mh_key) REFERENCES public.blocks(key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_node_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.header_cids
|
||||
ADD CONSTRAINT header_cids_node_id_fkey FOREIGN KEY (node_id) REFERENCES public.nodes(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_header_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES btc.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_mh_key_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_mh_key_fkey FOREIGN KEY (mh_key) REFERENCES public.blocks(key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs
|
||||
ADD CONSTRAINT tx_inputs_tx_id_fkey FOREIGN KEY (tx_id) REFERENCES btc.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_outputs tx_outputs_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_outputs
|
||||
ADD CONSTRAINT tx_outputs_tx_id_fkey FOREIGN KEY (tx_id) REFERENCES btc.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cids header_cids_mh_key_fkey; Type: FK CONSTRAINT; Schema: eth; Owner: -
|
||||
--
|
||||
@ -956,7 +643,7 @@ ALTER TABLE ONLY eth.receipt_cids
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY eth.state_accounts
|
||||
ADD CONSTRAINT state_accounts_state_id_fkey FOREIGN KEY (state_id) REFERENCES eth.state_cids(id) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT state_accounts_state_id_fkey FOREIGN KEY (state_id) REFERENCES eth.state_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user