#!/bin/bash

set -e

cd /home/mefluencr/public_html

echo "Pulling latest code..."
git fetch origin
git reset --hard origin/production

echo "Installing Composer dependencies..."
composer install \
    --no-dev \
    --prefer-dist \
    --optimize-autoloader \
    --no-interaction

# echo "Running migrations..."
# php artisan migrate --force

echo "Clearing caches..."
php artisan optimize:clear

echo "Caching..."
php artisan config:cache
php artisan route:cache
php artisan view:cache

# or simply:
# php artisan optimize

echo "Restarting queue..."
php artisan queue:restart || true

echo "Deployment complete!"