-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
42 lines (34 loc) 路 1.16 KB
/
Copy pathmakefile
File metadata and controls
42 lines (34 loc) 路 1.16 KB
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
.PHONY: run setup help migrate
# Load .env if it exists
-include .env
# --- Main Targets ---
run:
go run cmd/app/main.go
setup:
go mod tidy
help:
@echo "馃殌 Available commands:"
@echo ""
@echo " make run - Run the application"
@echo " make setup - Install Go dependencies"
@echo ""
@echo " make migrate-new NAME=xxx - Create new migration (e.g., make migrate-new NAME=create_users_table)"
@echo " make migrate-up - Apply all pending migrations"
@echo " make migrate-down - Rollback last migration"
@echo " make migrate-reset - Reset: down then up"
@echo ""
@echo "馃挕 Tip: Install 'migrate' CLI: go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"
# --- Migrations ---
migrate-new:
ifndef NAME
$(error Please specify NAME, e.g., make migrate-new NAME=create_users_table)
endif
migrate create -ext sql -dir migrations -seq $(NAME)
migrate-up:
migrate -path ./migrations -database "$(DB_URL)" -verbose up
migrate-down:
migrate -path ./migrations -database "$(DB_URL)" -verbose down
migrate-reset:
@echo "馃攧 Resetting migrations..."
make migrate-down
make migrate-up