-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (38 loc) · 1.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
GOTOOLS := \
github.com/alecthomas/gometalinter \
github.com/golang/dep/cmd/dep
DATABASE_NAME := send_it
DATABASE_USER := send_it_admin
.PHONY: tools
tools: ## First-time installation of development tools
go get -u $(GOTOOLS)
gometalinter --install
.PHONY: deps
deps: ## Ensure all dependencies are in sync
dep ensure
.PHONY: db-setup
db-setup: ## Create database
createuser --createdb $(DATABASE_USER)
createdb -U $(DATABASE_USER) $(DATABASE_NAME)
make db-migrate
.PHONY: db-migrate
db-migrate: ## Run new database migrations
go run cmd/migrations/*.go up
.PHONY: db-rollback
db-rollback: ## Rollback last run database migrations
go run cmd/migrations/*.go down
.PHONY: db-migrate-create
db-migrate-create: ## Add a migration: make db-migrate-create name=add_table
go run cmd/migrations/*.go create $(name)
.PHONY: db-reset
db-reset: ## Delete and recreate database
dropdb --if-exists $(DATABASE_NAME)
dropuser --if-exists $(DATABASE_USER)
make db-setup
.PHONY: run
run: ## Run application
gin --build ./cmd/serve --immediate run
.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := run