Files
CurrenciCombo/scripts/setup-database.sh
defiQUG 3dc8592b83 docs: Update CHANGELOG and README for deployment models and troubleshooting
- Added multi-platform deployment architecture details (Web App, PWA, DApp) to README.md.
- Included comprehensive troubleshooting guides and fix scripts in README.md.
- Enhanced CHANGELOG.md with new features, fixes, and improvements, including TypeScript error resolutions and updated documentation structure.
- Revised development setup instructions in DEV_SETUP.md to reflect changes in script usage and environment variable setup.
2025-11-06 08:09:54 -08:00

70 lines
2.2 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Database Setup Script
echo -e "\n========================================"
echo -e " DATABASE SETUP"
echo -e "========================================\n"
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo -e "\033[0;31m❌ Docker not found\033[0m"
echo -e " Please install Docker or set up PostgreSQL manually"
echo -e " See docs/DATABASE_OPTIONS.md for manual setup instructions"
exit 1
fi
echo -e "\033[0;32m✅ Docker found\033[0m"
# Check if container already exists
if docker ps -a --filter "name=combo-postgres" --format "{{.Names}}" | grep -q "combo-postgres"; then
echo -e "\n📦 Existing container found: combo-postgres"
# Check if running
if docker ps --filter "name=combo-postgres" --format "{{.Names}}" | grep -q "combo-postgres"; then
echo -e "\033[0;32m✅ Container is already running\033[0m"
else
echo -e "🔄 Starting existing container..."
docker start combo-postgres
sleep 3
fi
else
echo -e "\n📦 Creating new PostgreSQL container..."
docker run --name combo-postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=comboflow \
-p 5432:5432 \
-d postgres:15
echo -e "⏳ Waiting for database to initialize..."
sleep 5
fi
# Verify connection
echo -e "\n🔍 Verifying database connection..."
sleep 3
if nc -z localhost 5432 2>/dev/null; then
echo -e "\033[0;32m✅ PostgreSQL is running on port 5432\033[0m"
# Test connection
if docker exec combo-postgres psql -U postgres -d comboflow -c "SELECT 1;" > /dev/null 2>&1; then
echo -e "\033[0;32m✅ Database connection successful\033[0m"
else
echo -e "\033[0;33m⚠ Connection test failed\033[0m"
fi
else
echo -e "\033[0;31m❌ PostgreSQL is not listening on port 5432\033[0m"
echo -e " Check container logs: docker logs combo-postgres"
exit 1
fi
echo -e "\n\033[0;36m📝 Next steps:\033[0m"
echo -e " 1. Update orchestrator/.env with:"
echo -e " DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comboflow"
echo -e " RUN_MIGRATIONS=true"
echo -e "\n 2. Run migrations:"
echo -e " cd orchestrator"
echo -e " npm run migrate"
echo ""