#!/bin/bash
# Run AFTER the cPanel subdomain (moneywise.pa-desk.com -> ~/moneywise/public)
# and MySQL DB padesk_moneywise + user padesk_mwise (pass in .env) exist.
set -e
cd ~/moneywise
echo "==> migrating"; php artisan migrate --force
echo "==> seeding";  php artisan db:seed --force
echo "==> storage link"; php artisan storage:link || true
echo "==> caching config/routes/views"
php artisan config:cache
php artisan route:cache
php artisan view:cache
echo "==> permissions"; chmod -R 775 storage bootstrap/cache
echo "DONE. Visit https://moneywise.pa-desk.com"
echo "Admin login: admin@moneywise.co.ke / ChangeMe!2026  (CHANGE THIS after first login)"
