commit
3fb695c1e6
16
Makefile
16
Makefile
@ -1,10 +1,14 @@
|
||||
ifndef GOPATH
|
||||
override GOPATH = $(HOME)/go
|
||||
endif
|
||||
|
||||
BIN = $(GOPATH)/bin
|
||||
|
||||
# Tools
|
||||
## Migration tool
|
||||
GOOSE = $(BIN)/goose
|
||||
$(BIN)/goose:
|
||||
go get -u github.com/pressly/goose/cmd/goose
|
||||
GO111MODULE=off go get -u github.com/pressly/goose/cmd/goose
|
||||
|
||||
.PHONY: installtools
|
||||
installtools: | $(GOOSE)
|
||||
@ -50,6 +54,11 @@ rollback: $(GOOSE) checkdbvars
|
||||
rollback_to: $(GOOSE) checkmigration checkdbvars
|
||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
||||
|
||||
## Apply the next up migration
|
||||
.PHONY: migrate_up_by_one
|
||||
migrate_up_by_one: $(GOOSE) checkdbvars
|
||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up-by-one
|
||||
|
||||
## Apply all migrations not already run
|
||||
.PHONY: migrate
|
||||
migrate: $(GOOSE) checkdbvars
|
||||
@ -61,6 +70,11 @@ migrate: $(GOOSE) checkdbvars
|
||||
migrate_pre_batch_set: $(GOOSE) checkdbvars
|
||||
$(GOOSE) -dir db/pre_batch_processing_migrations postgres "$(CONNECT_STRING)" up
|
||||
|
||||
## Apply migrations to be ran after a batch processing, one-by-one
|
||||
.PHONY: migrate_post_batch_set_up_by_one
|
||||
migrate_post_batch_set_up_by_one: $(GOOSE) checkdbvars
|
||||
$(GOOSE) -dir db/post_batch_processing_migrations postgres "$(CONNECT_STRING)" up-by-one
|
||||
|
||||
## Apply migrations to be ran after a batch processing
|
||||
.PHONY: migrate_post_batch_set
|
||||
migrate_post_batch_set: $(GOOSE) checkdbvars
|
||||
|
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT pk_public_blocks PRIMARY KEY (key);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE public.blocks
|
||||
DROP CONSTRAINT pk_public_blocks;
|
@ -1,7 +1,4 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT pk_public_blocks PRIMARY KEY (key);
|
||||
|
||||
ALTER TABLE public.nodes
|
||||
ADD CONSTRAINT pk_public_nodes PRIMARY KEY (node_id);
|
||||
|
||||
@ -33,9 +30,6 @@ ALTER TABLE eth.state_accounts
|
||||
ADD CONSTRAINT pk_eth_state_accounts PRIMARY KEY (header_id, state_path);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE public.blocks
|
||||
DROP CONSTRAINT pk_public_blocks;
|
||||
|
||||
ALTER TABLE public.nodes
|
||||
DROP CONSTRAINT pk_public_nodes;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user