-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (38 loc) · 1.3 KB
/
Copy pathMakefile
File metadata and controls
48 lines (38 loc) · 1.3 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
43
44
45
46
47
# Load environment variables from .env if the file exists
ifneq ("$(wildcard .env)","")
include .env
export
endif
# Run the main application
run:
go run ./cmd/server/
# Create a new migration file
# Usage: make create-migration name=create_todos_table
create-migration:
migrate create -ext sql -dir sql/migration -seq $(name)
# Apply all available up migrations
migrate-up:
migrate -path sql/migration -database "$(PG_URL)" up
# Roll back the most recent migration
migrate-down:
migrate -path sql/migration -database "$(PG_URL)" down 1
# Roll back and re-apply the last migration (useful during development)
migrate-redo:
migrate -path sql/migration -database "$(PG_URL)" redo
# Show the current migration version
migrate-status:
migrate -path sql/migration -database "$(PG_URL)" version
# Force set the migration version
# Usage: make migrate-force version=1
migrate-force:
migrate -path sql/migration -database "$(PG_URL)" force $(version)
# Generate Go code from SQL using sqlc
sqlc-generate:
sqlc generate
# Generate Go code from Protobuf definitions
.PHONY: proto
proto-user:
protoc --proto_path=api/proto/user/v1 \
--go_out=api/proto/user/v1/gen --go_opt=paths=source_relative \
--go-grpc_out=api/proto/user/v1/gen --go-grpc_opt=paths=source_relative \
api/proto/user/v1/*.proto