-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
58 lines (46 loc) · 1.19 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
50
51
52
53
54
55
56
57
58
include .env
GO_BIN:=$(shell go env GOPATH)/bin
WD:=$(shell pwd)
MYSQL_INFO:=-h 127.0.0.1 -P 3306 -u root
DB_NAME:=sample
DML_DIR:=./migration/dml
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: run-db
run-db: ## create DB
docker-compose up --build -d mysql
.PHONY: run-go
run-go: ## run app
docker-compose up --build server
.PHONY: run-app
run-app: ## run app
docker-compose up --build
.PHONY: down
down: ## down
docker-compose down --rmi all --volumes --remove-orphans
# create DB table
.PHONY: migrate
migrate: ## migrate
migrate -path migration/ddl/ -database 'mysql://root:@tcp(localhost:3306)/$(DB_NAME)?parseTime=true&loc=Local' up
# insert data
.PHONY: seed
seed: ## seed
mysql $(MYSQL_INFO) $(DB_NAME) < $(DML_DIR)/dummy_students_insert.sql
# delete data
.PHONY: delete
delete: ## delete
mysql $(MYSQL_INFO) $(DB_NAME) < $(DML_DIR)/dummy_students_delete.sql
# .PHONY: init-local-db
# init-local-db:
# $(MAKE) run-db
# $(MAKE) migrate
# $(MAKE) seed
# create model using sqlboiler
.PHONY: generate-model
generate-model:
@$(GO_BIN)/sqlboiler mysql
# format code
.PHONY: fmt
fmt:
gofmt -l -w .