44 lines
1.0 KiB
Makefile
44 lines
1.0 KiB
Makefile
.PHONY: migrate-up migrate-down migrate-status goose-install run build clean
|
|
|
|
# Database connection string - update this to match your database
|
|
DB_URL="postgres://user:password@localhost:5432/quiz_app?sslmode=disable"
|
|
|
|
# Install goose
|
|
goose-install:
|
|
go install github.com/pressly/goose/v3/cmd/goose@latest
|
|
|
|
# Run all pending migrations
|
|
migrate-up:
|
|
goose -dir=migrations postgres "$(DB_URL)" up
|
|
|
|
# Rollback the last migration
|
|
migrate-down:
|
|
goose -dir=migrations postgres "$(DB_URL)" down
|
|
|
|
# Show migration status
|
|
migrate-status:
|
|
goose -dir=migrations postgres "$(DB_URL)" status
|
|
|
|
# Create a new migration file
|
|
create-migration:
|
|
@if [ -z "$(NAME)" ]; then \
|
|
echo "Usage: make create-migration NAME=name_of_migration"; \
|
|
exit 1; \
|
|
fi
|
|
goose -dir=migrations create $(NAME) sql
|
|
|
|
# Run the application
|
|
run:
|
|
go run cmd/server/main.go
|
|
|
|
# Build the application
|
|
build:
|
|
go build -o bin/server cmd/server/main.go
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -rf bin/
|
|
|
|
# Development setup
|
|
dev-setup: goose-install migrate-up
|
|
@echo "Development setup complete!"
|