@echo off
REM Complete schema fix for missing items columns
REM Run: double-click or right-click "Run as administrator"

echo Updating inventory schema...
echo.

cd /d "c:\xampp\htdocs\invcount"

echo [+] Applying full schema update...
"c:\xampp\mysql\bin\mysql.exe" -h127.0.0.1 --port=3306 -u root < full_schema_update.sql

if %ERRORLEVEL% EQU 0 (
    echo.
    echo [SUCCESS] Schema fully updated! 
    echo.
    echo ^> category, description, unit_of_measure, location, status columns added
    echo ^> Indexes created
    echo ^> Ready to use admin/items.php without errors
    echo.
    del fix_category_column.sql
    del run_fix.bat
    echo Cleanup complete.
) else (
    echo [ERROR] Update failed. Check XAMPP/MySQL service.
)

echo.
echo Press any key to exit...
pause >nul

