-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
31 lines (26 loc) · 806 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
30
31
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: confirm
confirm:
@echo 'Are you sure? [y/N]' && read ans && [ $${ans:-N} = y ]
## run/api: run cmd/api application
.PHONY: run/api
run/api:
@go run ./cmd/api
## db/psql: connect to the database using psql
.PHONY: db/psql
db/psql:
@psql ${MOVIES_DB}
## db/migration/new name=$1: create a new database migration
.PHONY: db/migration/new
db/migration/new:
@echo 'Creating migration files for ${name}...'
migrate create -seq -ext .sql -dir ./migrations ${name}
## db/migration/up: apply all up database migrations
.PHONY: db/migration/up
db/migration/up: confirm
@echo 'Running up migrations...'
migrate -path ./migrations -database ${MOVIES_DB} up