#!/usr/bin/env bash
# Run on cPanel via SSH from this folder (deploy/db-setup).
set -euo pipefail
cd "$(dirname "$0")"

if [[ ! -f .env ]]; then
  echo "Create .env from .env.example and set DATABASE_URL first."
  exit 1
fi

if ! command -v node >/dev/null 2>&1; then
  echo "Node.js is required. Load it with: source /home/USER/nodevenv/APP/VERSION/bin/activate"
  exit 1
fi

echo "Installing dependencies…"
npm install --omit=dev

echo "Applying schema…"
npm run schema

echo "Seeding demo data…"
npm run seed

echo "Done."
