#!/usr/bin/env bash
# Production deploy script for SpaceTV
# Run this on the production server after `git pull`.
set -euo pipefail

echo "→ Installing PHP dependencies (production)..."
composer install --no-dev --optimize-autoloader --no-interaction

echo "→ Installing JS dependencies..."
npm ci

echo "→ Building frontend assets..."
npm run build

echo "→ Running database migrations..."
php artisan migrate --force

echo "→ Ensuring storage symlink..."
php artisan storage:link || true

echo "→ Clearing & recaching Laravel..."
php artisan optimize:clear
php artisan optimize

echo "→ Restarting queues (if any)..."
php artisan queue:restart || true

echo "✓ Deployment complete."
