Files
cloudlense/frontend/scripts/setup-database.sh
T
Dennis 50e25e3ee8 refactor: flatten monorepo structure to backend/ frontend/ devops/
Rename subdirectories for a cleaner single-repo layout:
- website-monitoring-backend/  → backend/
- website-monitoring-frontend/ → frontend/
- website-monitoring-devops/   → devops/

Update all references in package.json scripts, CI workflows,
docker-compose, pre-commit hooks, and documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 00:25:29 +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!"