-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
74 lines (58 loc) · 1.8 KB
/
makefile
File metadata and controls
74 lines (58 loc) · 1.8 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Variables
BACKEND_BIN := backend_bin
TUI_BIN := tui_bin
BACKEND_SRC := cmd/backend/backend.go
TUI_SRC := cmd/tui/tui.go
DB_DIR := ./db/migrations
DB_USER := postgres
DB_PASSWORD := postgres
DB_NAME := scc
all: build
setup:
@go get tool
build: clean build-backend build-tui
build-backend: clean-backend
@echo "Building $(BACKEND_BIN)..."
@go build -o $(BACKEND_BIN) $(BACKEND_SRC)
build-tui: clean-tui
@echo "Building $(TUI_BIN)..."
@go build -o $(TUI_BIN) $(TUI_SRC)
clean: clean-backend clean-tui
clean-backend:
@if [ -f "$(BACKEND_BIN)" ]; then \
echo "Cleaning $(BACKEND_BIN)..."; \
rm -f "$(BACKEND_BIN)"; \
fi
clean-tui:
@if [ -f "$(TUI_BIN)" ]; then \
echo "Cleaning $(TUI_BIN)..."; \
rm -f "$(TUI_BIN)"; \
fi
backend:
@docker compose up -d
@go run $(BACKEND_SRC)
@docker compose down
tui:
@read -p "Enter screen name: " screen; \
go run $(TUI_SRC) -screen $$screen
goose:
@docker compose down
@docker compose up db -d
@docker compose exec db bash -c 'until pg_isready -U postgres; do sleep 1; done'
@read -p "Action: " action; \
go tool goose -dir ./db/migrations postgres "user=postgres password=postgres host=localhost port=5432 dbname=scc sslmode=disable" $$action
@docker compose down db
migrate:
@docker compose down
@docker compose up db -d
@docker compose exec db bash -c 'until pg_isready -U postgres; do sleep 1; done'
@go tool goose -dir ./db/migrations postgres "user=postgres password=postgres host=localhost port=5432 dbname=scc sslmode=disable" up
@docker compose down db
create-migration:
@read -p "Enter migration name: " name; \
go tool goose -dir ./db/migrations create $$name sql
query:
@go tool sqlc generate
dead:
@go tool deadcode ./...
.PHONY: all setup build build-backed build-tui clean clean-backend clean-tui backend tui create-migration goose query dead