2018-01-25 21:46:55 +00:00
|
|
|
HOST_NAME =
|
|
|
|
PORT =
|
|
|
|
NAME =
|
2018-01-25 19:21:55 +00:00
|
|
|
CONNECT_STRING=postgresql://$(HOST_NAME):$(PORT)/$(NAME)?sslmode=disable
|
|
|
|
|
|
|
|
$(MATTESMIGRATE):
|
|
|
|
go get -u -d github.com/mattes/migrate/cli github.com/lib/pq
|
|
|
|
go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli
|
|
|
|
|
|
|
|
$(DEP):
|
|
|
|
go get -u github.com/golang/dep/cmd/dep
|
|
|
|
|
|
|
|
$(GINKGO):
|
|
|
|
go get -u github.com/onsi/ginkgo/ginkgo
|
|
|
|
|
|
|
|
checkdbvars:
|
2018-01-25 21:46:55 +00:00
|
|
|
test -n "$(HOST_NAME)" # $$HOST_NAME
|
2018-01-25 19:21:55 +00:00
|
|
|
test -n "$(PORT)" # $$PORT
|
|
|
|
test -n "$(NAME)" # $$NAME
|
|
|
|
|
|
|
|
rollback: checkdbvars
|
|
|
|
migrate -database $(CONNECT_STRING) -path ./db/migrations down 1
|
|
|
|
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
|
|
|
|
|
|
|
migrate: $(MATTESMIGRATE) checkdbvars
|
|
|
|
migrate -database $(CONNECT_STRING) -path ./db/migrations up
|
|
|
|
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
|
|
|
|
2018-01-25 21:46:55 +00:00
|
|
|
import:
|
|
|
|
test -n "$(NAME)" # $$NAME
|
|
|
|
psql $(NAME) < db/schema.sql
|
|
|
|
|
2018-01-25 19:21:55 +00:00
|
|
|
dep: $(DEP)
|
|
|
|
dep ensure
|
|
|
|
|
2018-01-25 21:46:55 +00:00
|
|
|
build: dep
|
|
|
|
go build
|
2018-01-25 19:21:55 +00:00
|
|
|
|
|
|
|
test: $(GINKGO)
|
|
|
|
ginkgo -r
|