-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
29 lines (22 loc) · 845 Bytes
/
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
include .env
DB_MIGRATION_DIR := database/migrations
DB_MYSQL_DSN := mysql://${DB_USER}:${DB_PASS}@tcp'('${DB_HOST}:${DB_PORT}')'/${DB_NAME}
# install installs dependencies and tools
install:
go install github.com/githubnemo/CompileDaemon@latest
go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.15.0
# run executes the main.go file
run:
go run ./cmd/api/main.go
# build compiles the project to /bin
build:
go build -o ./cmd/api/ ./cmd/api/main.go
# dev runs a dev server
dev:
CompileDaemon -exclude=*_test.go -build="make build" -command="./cmd/api/main"
# migrateup migrates up the mysql db
migrateup:
migrate -path $(DB_MIGRATION_DIR) -database $(DB_MYSQL_DSN) -verbose up
# migratedown migrates down the mysql db
migratedown:
migrate -path $(DB_MIGRATION_DIR) -database $(DB_MYSQL_DSN) -verbose down