#!/bin/bash # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}๐Ÿ› ๏ธ Development Helper Script${NC}" echo "=============================" show_help() { echo -e "${BLUE}Available commands:${NC}" echo " db-shell [postgres|mongo|redis] - Connect to database shell" echo " test-db - Test all database connections" echo " test-rabbitmq - Test RabbitMQ queues" echo " reset-db - Reset all databases" echo " quick-start - Start only essential services" echo " health - Comprehensive health check" echo "" } case $1 in "db-shell") case $2 in "postgres") echo -e "${BLUE}๐Ÿ˜ Connecting to PostgreSQL...${NC}" docker-compose exec postgres psql -U pipeline_admin -d dev_pipeline ;; "mongo") echo -e "${BLUE}๐Ÿƒ Connecting to MongoDB...${NC}" docker-compose exec mongodb mongosh ;; "redis") echo -e "${BLUE}๐Ÿ”ด Connecting to Redis...${NC}" docker-compose exec redis redis-cli ;; *) echo -e "${RED}โŒ Please specify: postgres, mongo, or redis${NC}" ;; esac ;; "test-db") echo -e "${BLUE}๐Ÿงช Testing database connections...${NC}" echo -n "PostgreSQL: " if docker-compose exec -T postgres psql -U pipeline_admin -d dev_pipeline -c "SELECT version();" > /dev/null 2>&1; then echo -e "${GREEN}โœ…${NC}" else echo -e "${RED}โŒ${NC}" fi echo -n "MongoDB: " if docker-compose exec -T mongodb mongosh --eval "db.runCommand('ping')" --quiet > /dev/null 2>&1; then echo -e "${GREEN}โœ…${NC}" else echo -e "${RED}โŒ${NC}" fi echo -n "Redis: " if docker-compose exec -T redis redis-cli ping | grep -q PONG; then echo -e "${GREEN}โœ…${NC}" else echo -e "${RED}โŒ${NC}" fi ;; "test-rabbitmq") echo -e "${BLUE}๐Ÿงช Testing RabbitMQ...${NC}" if [ -f "scripts/rabbitmq/test-queues.py" ]; then python3 scripts/rabbitmq/test-queues.py else echo -e "${RED}โŒ RabbitMQ test script not found${NC}" fi ;; "reset-db") echo -e "${YELLOW}โš ๏ธ This will reset ALL databases!${NC}" read -p "Are you sure? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${BLUE}๐Ÿ”„ Resetting databases...${NC}" docker-compose down docker volume rm $(docker volume ls -q | grep pipeline) 2>/dev/null || true docker-compose up -d postgres redis mongodb rabbitmq echo -e "${GREEN}โœ… Databases reset${NC}" fi ;; "quick-start") echo -e "${BLUE}๐Ÿš€ Quick start - essential services only...${NC}" docker-compose up -d postgres redis mongodb rabbitmq ;; "health") echo -e "${BLUE}๐Ÿฅ Comprehensive health check...${NC}" ./scripts/setup/status.sh ;; *) show_help ;; esac