Files
cloudlense/website-monitoring-frontend/scripts/setup-database.sh
T
Dennis 14a32bdc0d feat: initialize monorepo with full dev team best practices
- Unified monorepo with backend (Express), frontend (Next.js), and devops
- Backend: ESLint, Prettier, Jest tests (3 passing), health endpoint, .env.example
- Frontend: Fixed build errors, fixed all lint errors (0 remaining), tests passing
- DevOps: Docker Compose with PostgreSQL, backend, frontend + healthchecks
- CI/CD: 3 GitHub Actions workflows (backend, frontend, docker integration)
- DX: Husky pre-commit hooks with smart change detection
- Docs: Root README with architecture, CONTRIBUTING.md, PR template

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-06 00:05:50 +01:00

26 lines
1.1 KiB
Bash

#!/bin/bash
# Setup database for website monitoring frontend
echo "Setting up database..."
# Start PostgreSQL service if not running
if ! pg_isready -h localhost -p 5432 > /dev/null 2>&1; then
echo "Starting PostgreSQL service..."
devenv up &
sleep 5
fi
# Create database and user if they don't exist
psql -h localhost -U postgres -c "CREATE DATABASE website_monitoring;" 2>/dev/null || echo "Database already exists"
psql -h localhost -U postgres -c "CREATE USER website_monitoring WITH PASSWORD 'password';" 2>/dev/null || echo "User already exists"
psql -h localhost -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE website_monitoring TO website_monitoring;" 2>/dev/null
# Run the schema setup
echo "Running database schema setup..."
psql -h localhost -U website_monitoring -d website_monitoring -f setup-database.sql
# Add missing column if it doesn't exist
echo "Adding missing scheduled_at column..."
psql -h localhost -U website_monitoring -d website_monitoring -c "ALTER TABLE scans ADD COLUMN IF NOT EXISTS scheduled_at TIMESTAMPTZ;"
echo "Database setup complete!"