-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 1.59 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
BINARY_NAME=renco-boilerplate
build:
@go build -o bin/${BINARY_NAME} main.go
run-http:
@./bin/${BINARY_NAME} http
install:
@echo "Installing dependencies...."
@rm -rf vendor
@rm -f Gopkg.lock
@rm -f glide.lock
@go mod tidy && go mod download && go mod vendor
start-http:
@go run main.go http
# Define the base command for migration
MIGRATE_CMD=go run main.go db:migrate
# Default target
.DEFAULT_GOAL := help
# Show help message
help:
@echo "Usage:"
@echo " make migrate-status # Show migration status"
@echo " make migrate-up # Apply all pending migrations"
@echo " make migrate-redo # Redo the most recent migration"
@echo " make migrate-reset # Rollback all migrations and reapply"
@echo " make migrate-fix # Fix broken migrations"
@echo " make migrate-create # Create a new migration with a specified name"
@echo " make migrate-create NAME=<migration_name> [TYPE=sql] # Create a new migration with specified name and type"
# Show migration status
migrate-status:
@$(MIGRATE_CMD) status
# Apply all pending migrations
migrate-up:
@$(MIGRATE_CMD) up
# Redo the most recent migration
migrate-redo:
@$(MIGRATE_CMD) redo
# Rollback all migrations and reapply
migrate-reset:
@$(MIGRATE_CMD) reset
# Fix broken migrations
migrate-fix:
@$(MIGRATE_CMD) fix
# Create a new migration
migrate-create:
@$(MIGRATE_CMD) create ${NAME} ${TYPE}
# Usage examples:
# To create a migration named 'users' with SQL type:
# make migrate-create NAME=users TYPE=sql
#
# To create a migration named 'orders' with default type (if TYPE is not provided):
# make migrate-create NAME=orders