.PHONY: up down reset-db logs dev migrate

up:
	docker compose up -d

down:
	docker compose down

logs:
	docker compose logs -f

reset-db:
	docker compose down -v
	docker compose up -d postgres redis
	@echo "Waiting for postgres to be ready..."
	@for i in $$(seq 1 30); do \
		docker compose exec -T postgres pg_isready -U nexusguard >/dev/null 2>&1 && break; \
		echo "  waiting... $$i"; \
		sleep 2; \
	done
	docker compose run --rm server-core ./server-core -migrate-prod
	@echo ""
	@echo "Database reset complete. Run 'make up' to start all services."

dev:
	docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d

migrate:
	docker compose run --rm server-core ./server-core -migrate-prod
