#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BACKUP="$ROOT/storage/backups/customer-journey-v1-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP"

for f in app/Services/ProgramJourneyService.php app/Controllers/ProgramJourneyController.php; do
  if [ -f "$ROOT/$f" ]; then
    mkdir -p "$BACKUP/$(dirname "$f")"
    cp -a "$ROOT/$f" "$BACKUP/$f"
  fi
done

php -l "$ROOT/app/Services/ProgramJourneyService.php"
php -l "$ROOT/app/Controllers/ProgramJourneyController.php"

echo "Customer Journey V1 code verification: PASS"
echo "Migration: database/migrations/006_customer_journey.sql"
echo "Next: run the existing installer endpoint to apply pending migration 006."
echo "Backup: $BACKUP"
