2019-01-22 12:15:29 +00:00
|
|
|
-- +goose Up
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER TABLE public.nodes
|
|
|
|
RENAME TO eth_nodes;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER TABLE public.eth_nodes
|
|
|
|
RENAME COLUMN node_id TO eth_node_id;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.eth_nodes
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT node_uc;
|
|
|
|
ALTER TABLE public.eth_nodes
|
|
|
|
ADD CONSTRAINT eth_node_uc UNIQUE (genesis_block, network_id, eth_node_id);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER TABLE public.blocks
|
|
|
|
RENAME COLUMN node_id TO eth_node_id;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.blocks
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT node_id_block_number_uc;
|
|
|
|
ALTER TABLE public.blocks
|
|
|
|
ADD CONSTRAINT eth_node_id_block_number_uc UNIQUE (number, eth_node_id);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.blocks
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT node_fk;
|
|
|
|
ALTER TABLE public.blocks
|
|
|
|
ADD CONSTRAINT node_fk
|
|
|
|
FOREIGN KEY (eth_node_id) REFERENCES eth_nodes (id) ON DELETE CASCADE;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- +goose Down
|
|
|
|
ALTER TABLE public.eth_nodes
|
2019-08-06 21:57:08 +00:00
|
|
|
RENAME TO nodes;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.nodes
|
2019-08-06 21:57:08 +00:00
|
|
|
RENAME COLUMN eth_node_id TO node_id;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.nodes
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT eth_node_uc;
|
2019-01-22 12:15:29 +00:00
|
|
|
ALTER TABLE public.nodes
|
2019-08-06 21:57:08 +00:00
|
|
|
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER TABLE public.blocks
|
|
|
|
RENAME COLUMN eth_node_id TO node_id;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.blocks
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT eth_node_id_block_number_uc;
|
|
|
|
ALTER TABLE public.blocks
|
|
|
|
ADD CONSTRAINT node_id_block_number_uc UNIQUE (number, node_id);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
ALTER TABLE public.blocks
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP CONSTRAINT node_fk;
|
|
|
|
ALTER TABLE public.blocks
|
|
|
|
ADD CONSTRAINT node_fk
|
|
|
|
FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE;
|