@echo off
REM Batch script to execute ENUM fix using psql
REM If psql is not in PATH, update the PSQL_PATH variable below

SET PSQL_PATH=psql
SET PGPASSWORD=PDmXRx0Rbk9OFOn9qO5Gm/mPCfqW8zwbZ+/YIU1lySc=
SET PGHOST=94.130.218.54
SET PGPORT=5432
SET PGUSER=postgres
SET PGDATABASE=Sales

echo Executing ENUM fix on remote database...
echo Host: %PGHOST%:%PGPORT%
echo Database: %PGDATABASE%
echo.

%PSQL_PATH% -h %PGHOST% -p %PGPORT% -U %PGUSER% -d %PGDATABASE% -f "fix-enum-types-comprehensive.sql"

if %ERRORLEVEL% EQU 0 (
    echo.
    echo SUCCESS: ENUM fix executed successfully!
    echo Please restart your Spring Boot application.
) else (
    echo.
    echo ERROR: Failed to execute ENUM fix. Error code: %ERRORLEVEL%
    echo.
    echo If psql is not found, please install PostgreSQL client tools or use a GUI tool like DBeaver.
)

pause
