Files
go-playground/projects/greenlight/Makefile
T
2026-04-29 15:38:06 +02:00

35 lines
865 B
Makefile

include .env
## 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 -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
## run/api: run the cmd/api application
.PHONY: run/api
run/api:
go run ./cmd/api -db-dsn=${DATABASE_DSN}
## db/psql: connect to the database using psql
.PHONY: db/psql
db/psql:
psql ${DATABASE_DSN}
## db/migrations/new name=$1: create a new database migration
.PHONY: db/migrations/new
db/migrations/new:
@echo 'Creating migration files for ${name}...'
migrate create -seq -ext=.sql -dir=./migrations ${name}
## db/migrations/up: apply all up database migrations
.PHONY: db/migrations/up
db/migrations/up: confirm
@echo 'Running up migrations...'
migrate -path ./migrations -database ${DATABASE_DSN} up