#!/command/with-contenv bash
# Runs on every container start (after DB/Redis are reachable on the Coolify network).
# NOTE: no `set -e` — cache warmup must never crash container startup.

cd /var/www/html

# Storage symlink (idempotent)
php artisan storage:link 2>/dev/null || true

# Run pending migrations
php artisan migrate --force --no-interaction || true

# Cache config + views for production speed
php artisan config:cache || true
php artisan view:cache || true

# route:cache intentionally SKIPPED: app has Closure-based routes
# (routes/web.php + api.php) which Laravel cannot serialize. Refactoring
# those closures into controllers would allow enabling route:cache later.

exit 0
