#!/bin/bash
# ============================================================
#  Women Thrive by Design — One-shot deploy script
#  Run this ONCE after uploading and unzipping on the server:
#  bash /home/sxsdedzw/public_html/backend/deploy.sh
# ============================================================

BASE=/home/sxsdedzw/public_html/backend

echo ">>> Creating storage directories..."
mkdir -p $BASE/storage/framework/views
mkdir -p $BASE/storage/framework/cache
mkdir -p $BASE/storage/framework/sessions
mkdir -p $BASE/storage/logs

echo ">>> Setting permissions..."
find $BASE -type f -exec chmod 644 {} \;
find $BASE -type d -exec chmod 755 {} \;
chmod -R 775 $BASE/storage
chmod -R 775 $BASE/bootstrap/cache
chmod +x $BASE/artisan

echo ">>> Running artisan commands..."
php $BASE/artisan config:clear
php $BASE/artisan cache:clear
php $BASE/artisan view:clear
php $BASE/artisan route:clear
php $BASE/artisan storage:link
php $BASE/artisan optimize

echo ""
echo "============================================================"
echo " Done! Visit https://womenthrivebydesign.xyz/admin/login"
echo " Email:    admin@womenthrivebydesign.com"
echo " Password: Decree2026!"
echo "============================================================"
