-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (42 loc) · 1.64 KB
/
Makefile
File metadata and controls
46 lines (42 loc) · 1.64 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
.PHONY: migrate migrate-help migrate-build clean
# Build the migration tool
migrate-build:
@mkdir -p migrate/bin
@echo "Building migration tool..."
@rm -f migrate/bin/migrate
cd migrate && CGO_ENABLED=0 go build -v -o bin/migrate migrate.go
@chmod +x migrate/bin/migrate
@echo "Build successful"
@file migrate/bin/migrate
# Run migration with default parameters (requires DB credentials)
migrate: migrate-build
@echo "Usage: make migrate ENTITY=<entity> USER=<user> PASSWORD=<password> DB=<database> [HOST=<host>] [PORT=<port>] [SSL=<ssl>]"
@echo "Example: make migrate ENTITY=user USER=postgres PASSWORD=mypass DB=myapp"
@echo ""
@if [ -z "$(ENTITY)" ] || [ -z "$(USER)" ] || [ -z "$(DB)" ]; then \
echo "Error: Missing required parameters. Use 'make migrate-help' for usage."; \
exit 1; \
fi
@echo "Running migration..."
./migrate/bin/migrate -entity=$(ENTITY) -user=$(USER) -db=$(DB) -password=$(PASSWORD) -host=$(HOST) -port=$(PORT) -ssl=$(SSL) || true
rm -rf migrate/bin
# Show detailed help
migrate-help:
@echo "Migration Tool Usage:"
@echo ""
@echo "Required parameters:"
@echo " ENTITY - Entity name (e.g., 'user', 'admin')"
@echo " USER - Database user"
@echo " DB - Database name"
@echo ""
@echo "Optional parameters:"
@echo " PASSWORD - Database password"
@echo " HOST - Database host (default: localhost)"
@echo " PORT - Database port (default: 5432)"
@echo " SSL - SSL mode: disable, require (default: disable)"
@echo ""
@echo "Examples:"
@echo " make migrate ENTITY=user USER=postgres PASSWORD=secret DB=prod HOST=db.example.com SSL=require"
# Clean built binaries
clean:
rm -rf migrate/bin