@echo off
echo Setting up MySQL database for Kenyan POS...

REM Check if MySQL is available
mysql --version >nul 2>&1
if %errorlevel% neq 0 (
    echo MySQL is not installed or not in PATH
    echo Please install MySQL or XAMPP/WAMP and try again
    pause
    exit /b 1
)

REM Create database
echo Creating database...
mysql -u root -p < setup-database.sql

if %errorlevel% equ 0 (
    echo Database created successfully!
    echo Running Laravel migrations...
    php artisan migrate:fresh --seed
    
    if %errorlevel% equ 0 (
        echo Setup completed successfully!
        echo You can now run: php artisan serve
    ) else (
        echo Migration failed. Please check your database connection.
    )
) else (
    echo Database creation failed. Please check your MySQL connection.
)

pause