use separate mig for new chainID field so we can apply to current db

This commit is contained in:
ramil 2020-10-20 20:50:20 +03:00
parent bf46200c07
commit 98f5a16771
2 changed files with 22 additions and 2 deletions

View File

@ -5,8 +5,7 @@ CREATE TABLE nodes (
genesis_block VARCHAR(66), genesis_block VARCHAR(66),
network_id VARCHAR, network_id VARCHAR,
node_id VARCHAR(128), node_id VARCHAR(128),
chain_id INTEGER, CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id)
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id)
); );
-- +goose Down -- +goose Down

View File

@ -0,0 +1,21 @@
-- +goose Up
ALTER TABLE public.nodes
ADD COLUMN chain_id INTEGER DEFAULT 1;
ALTER TABLE public.nodes
DROP CONSTRAINT node_uc;
ALTER TABLE public.nodes
ADD CONSTRAINT node_uc
UNIQUE (genesis_block, network_id, node_id, chain_id);
-- +goose Down
ALTER TABLE public.nodes
DROP CONSTRAINT node_uc;
ALTER TABLE public.nodes
ADD CONSTRAINT node_uc
UNIQUE (genesis_block, network_id, node_id);
ALTER TABLE public.nodes
DROP COLUMN chain_id;