-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
53 lines (39 loc) · 1.15 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
ifneq (,$(wildcard ./app.env))
include app.env
export $(shell sed 's/=.*//' app.env)
endif
MIGRATE_PATH = ./scripts/migrations
DATABASE_URL = ${DB_SOURCE}
format:
@echo "Applying go fmt to the project"
go fmt ./...
vet:
@echo "Checking for errors with vet"
go vet ./...
dockerup:
docker compose --env-file app.env up -d
dockerdown:
docker compose --env-file app.env down
migrate-create:
@echo "Creating migration files for ${name}..."
migrate create -seq -ext=.sql -dir=./scripts/migrations ${name}
migrate-up:
@echo "Running up migrations..."
migrate -path ${MIGRATE_PATH} -database "${DATABASE_URL}" up
migrate-down:
@echo "Rolling back migrations..."
@if [ -z "$(n)" ]; then \
migrate -path ${MIGRATE_PATH} -database "${DATABASE_URL}" down 1; \
else \
migrate -path ${MIGRATE_PATH} -database "${DATABASE_URL}" down $(n); \
fi
migrate-drop:
@echo "Dropping all migrations..."
migrate -path ${MIGRATE_PATH} -database "${DATABASE_URL}" drop -f
# Run the HTTP server
http:
go run . http
seed:
go run . seed
# Declare targets that are not files
.PHONY: format vet dockerup dockerdown migrate-create migrate-up migrate-down migrate-drop http seed