#!/bin/sh

echo "=== Starting BurnRegister Backend Boot Sequence ==="

# 1. Run migrations
echo "Running database migrations..."
if php artisan migrate --force; then
    echo "SUCCESS: Database migrations completed."
else
    echo "WARNING: Database migrations failed. The server will start anyway, but API endpoints requiring database access will fail."
fi

# 2. Start the Laravel web server
echo "Starting Laravel built-in web server on port $PORT..."
exec php artisan serve --host=0.0.0.0 --port=$PORT
