From 0a02fe4e033ab01f091ea2886f014d8b414a8b27 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Wed, 29 Apr 2026 02:57:50 +0300 Subject: [PATCH] feat: Replace custom migration runner with goose CLI and add migration management commands to Makefile - Replace custom Go migration runner (go run cmd/migrate/main.go) with goose postgres command in db-migrate target - Add db-migrate-down target for rolling back migrations - Add db-migrate-status target to show current migration status - Add db-create-migration target for creating new migration files with NAME parameter validation - Add db-migrate-rust target for Rust service migrations (uses same --- Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9636a3c..ec135cc 100644 --- a/Makefile +++ b/Makefile @@ -181,11 +181,30 @@ db-setup: ## Set up PostgreSQL, MongoDB and Redis @bash scripts/setup-redis.sh @echo "$(GREEN)Database setup complete!$(RESET)" -db-migrate: ## Run database migrations +db-migrate: ## Run database migrations (Go and Rust) @echo "$(CYAN)Running database migrations...$(RESET)" - @cd apps/api-server && go run cmd/migrate/main.go + @goose postgres $(DATABASE_URL) up migrations @echo "$(GREEN)Migrations complete!$(RESET)" +db-migrate-down: ## Rollback database migrations + @echo "$(CYAN)Rolling back database migrations...$(RESET)" + @goose postgres $(DATABASE_URL) down migrations + @echo "$(GREEN)Rollback complete!$(RESET)" + +db-migrate-status: ## Show migration status + @echo "$(CYAN)Migration status:$(RESET)" + @goose postgres $(DATABASE_URL) status migrations + +db-create-migration: ## Create a new migration file (usage: make db-create-migration NAME=migration_name) + @echo "$(CYAN)Creating new migration...$(RESET)" + @if [ -z "$(NAME)" ]; then echo "Error: NAME parameter is required. Usage: make db-create-migration NAME=migration_name"; exit 1; fi + @goose create $(NAME) sql + +db-migrate-rust: ## Run migrations for Rust services (uses goose binary) + @echo "$(CYAN)Running migrations for Rust services...$(RESET)" + @goose postgres $(DATABASE_URL) up migrations + @echo "$(GREEN)Rust migrations complete!$(RESET)" + # Free5GC integration free5gc-setup: ## Set up free5GC configuration files @echo "$(CYAN)Setting up free5GC configuration...$(RESET)"