Skip to content

Commit e573c8a

Browse files
committed
chore: Update Makefile
1 parent 34921d3 commit e573c8a

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

Makefile

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
DB_URL=postgres://postgres:postgres@localhost:5432/books?sslmode=disable
22
MIGRATIONS_DIR=./db/migrations
33

4-
migrate-up:
4+
.PHONY: help migrate-up migrate-down migrate-force sqlc-gen psql up down build clean
5+
6+
help: ## Prints all targets
7+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
8+
9+
migrate-up: ## Migrate up database
510
migrate -database "$(DB_URL)" -path $(MIGRATIONS_DIR) up
611

7-
migrate-down:
12+
migrate-down: ## Migrate down database
813
migrate -database "$(DB_URL)" -path $(MIGRATIONS_DIR) down
914

10-
migrate-force:
15+
migrate-force: ## Force migrate database to version 1
1116
migrate -database "$(DB_URL)" -path $(MIGRATIONS_DIR) force 1
1217

13-
sqlc-gen:
18+
sqlc-gen: ## Generate Go code from SQL using sqlc
1419
sqlc generate
1520

16-
psql:
21+
psql: ## Open interactive psql session
1722
psql $(DB_URL)
1823

19-
drop-db:
20-
dropdb --if-exists -U postgres books
21-
22-
up:
24+
up: ## Start services via docker-compose
2325
docker-compose up -d
2426

25-
down:
27+
down: ## Stop services via docker-compose
2628
docker-compose down
2729

28-
seed:
29-
psql $(DB_URL) -f db/seed.sql
30-
31-
.PHONY: migrate-up migrate-down migrate-new migrate-force sqlc-gen create-db drop-db psql up down logs
30+
build: ## Compile the Go application
31+
go build -o bin/semantic-search ./cmd/main.go
32+
33+
clean: ## Clean build files (asks for confirmation)
34+
@read -p "Are you sure you want to delete ./bin? [y/N] " confirm; \
35+
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
36+
echo "Cleaning..."; \
37+
rm -rf bin/; \
38+
else \
39+
echo "Aborted."; \
40+
fi

0 commit comments

Comments
 (0)