-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
51 lines (35 loc) · 1.7 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
.PHONY: help database-up database-down migration-up migration-down local run
help:
@echo "Available targets:"
@echo " make database-up - Start the database container"
@echo " make database-down - Stop and remove the database container"
@echo " make migration-up - Run database migrations"
@echo " make migration-down - Rollback database migrations"
@echo " make local - Run the application locally"
@echo " make run - Start the database, run migrations, and start the application locally"
@echo " make down - Shutdown the database and down migrations"
# Directory where migration files are located
MIGRATION_DIR := database/mysql/migration
# This target waits for the MySQL container to become available
wait-for-mysql:
@echo "Waiting for MySQL container to start..."
@until docker compose exec mysql-db mysql -umysql -ppwd -hlocalhost -e "SELECT 1"; do \
sleep 6; \
done
@echo "MySQL is up and running!"
database-up:
docker compose up -d
database-down:
docker compose down
migration-up: wait-for-mysql
GOOSE_DRIVER=mysql GOOSE_DBSTRING="mysql:pwd@tcp(localhost:3306)/users?parseTime=true" goose -dir=$(MIGRATION_DIR) up
migration-down:
GOOSE_DRIVER=mysql GOOSE_DBSTRING="mysql:pwd@tcp(localhost:3306)/users?parseTime=true" goose -dir=$(MIGRATION_DIR) down
local:
env="local" go run cmd/main.go
run: database-up migration-up local
down : migration-down database-down
mock-repository:
mockgen -source internal/$(domain)/repository/repository.go -destination internal/$(domain)/mock/repository_mock.go -package=mocks
mock-usecase:
mockgen -source internal/$(domain)/usecase/usecase.go -destination internal/$(domain)/mock/usecase_mock.go -package=mocks