-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
executable file
·46 lines (35 loc) · 1.98 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
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
# ==================================================================================== #
# SQL MIGRATIONS
# ==================================================================================== #
## migrations/new name=$1: create a new database migration
.PHONY: migrations/new
migrations/new:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest create -seq -ext=.sql -dir=./assets/migrations ${name}
## migrations/up: apply all up database migrations
.PHONY: migrations/up
migrations/up:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path=./assets/migrations -database="postgres://${DB_DSN}" up
## migrations/down: apply all down database migrations
.PHONY: migrations/down
migrations/down:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path=./assets/migrations -database="postgres://${DB_DSN}" down
## migrations/goto version=$1: migrate to a specific version number
.PHONY: migrations/goto
migrations/goto:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path=./assets/migrations -database="postgres://${DB_DSN}" goto ${version}
## migrations/force version=$1: force database migration
.PHONY: migrations/force
migrations/force:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path=./assets/migrations -database="postgres://${DB_DSN}" force ${version}
## migrations/version: print the current in-use migration version
.PHONY: migrations/version
migrations/version:
go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest -path=./assets/migrations -database="postgres://${DB_DSN}" version