Files
CurrenciCombo/scripts/setup-database.ps1
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

77 lines
3.0 KiB
PowerShell

# Database Setup Script
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host " DATABASE SETUP" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
# Check if Docker is available
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
Write-Host "❌ Docker not found" -ForegroundColor Red
Write-Host " Please install Docker Desktop or set up PostgreSQL manually" -ForegroundColor Yellow
Write-Host " See docs/DATABASE_OPTIONS.md for manual setup instructions" -ForegroundColor Gray
exit 1
}
Write-Host "[OK] Docker found" -ForegroundColor Green
# Check if container already exists
$existing = docker ps -a --filter "name=combo-postgres" --format "{{.Names}}"
if ($existing) {
Write-Host "`n📦 Existing container found: $existing" -ForegroundColor Yellow
# Check if running
$running = docker ps --filter "name=combo-postgres" --format "{{.Names}}"
if ($running) {
Write-Host "[OK] Container is already running" -ForegroundColor Green
} else {
Write-Host "🔄 Starting existing container..." -ForegroundColor Yellow
docker start combo-postgres
Start-Sleep -Seconds 3
}
} else {
Write-Host "`n📦 Creating new PostgreSQL container..." -ForegroundColor Yellow
docker run --name combo-postgres `
-e POSTGRES_PASSWORD=postgres `
-e POSTGRES_DB=comboflow `
-p 5432:5432 `
-d postgres:15
Write-Host "⏳ Waiting for database to initialize..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
}
# Verify connection
Write-Host "`n🔍 Verifying database connection..." -ForegroundColor Yellow
Start-Sleep -Seconds 3
$portCheck = Get-NetTCPConnection -LocalPort 5432 -State Listen -ErrorAction SilentlyContinue
if ($portCheck) {
Write-Host "[OK] PostgreSQL is running on port 5432" -ForegroundColor Green
# Test connection
try {
$testResult = docker exec combo-postgres psql -U postgres -d comboflow -c "SELECT 1;" 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[OK] Database connection successful" -ForegroundColor Green
} else {
Write-Host "⚠️ Connection test failed" -ForegroundColor Yellow
}
} catch {
Write-Host "⚠️ Could not test connection: $_" -ForegroundColor Yellow
}
} else {
Write-Host "❌ PostgreSQL is not listening on port 5432" -ForegroundColor Red
Write-Host " Check container logs: docker logs combo-postgres" -ForegroundColor Gray
exit 1
}
Write-Host "`n📝 Next steps:" -ForegroundColor Cyan
Write-Host " 1. Update orchestrator/.env with:" -ForegroundColor White
Write-Host " DATABASE_URL=postgresql://postgres:postgres@localhost:5432/comboflow" -ForegroundColor Gray
Write-Host " RUN_MIGRATIONS=true" -ForegroundColor Gray
Write-Host "`n 2. Run migrations:" -ForegroundColor White
Write-Host " cd orchestrator" -ForegroundColor Gray
Write-Host " npm run migrate" -ForegroundColor Gray
Write-Host ""