@echo off
REM Add missing base performance indexes to Jellyfin database

echo ========================================
echo Add Base Performance Indexes
echo ========================================
echo.
echo These indexes were missing from InitialCreate
echo Adding 18 essential performance indexes...
echo.

"C:\Program Files\PostgreSQL\18\bin\psql.exe" -U jellyfin -d jellyfin -f sql\add_base_performance_indexes.sql

if %ERRORLEVEL% EQU 0 (
    echo.
    echo ========================================
    echo Success! Base indexes added.
    echo ========================================
    echo.
    echo Indexes created:
    echo - 9 on BaseItems
    echo - 2 on BaseItemProviders  
    echo - 2 on MediaStreamInfos
    echo - 2 on PeopleBaseItemMap
    echo - 3 on UserData
    echo.
    echo Next: Restart Jellyfin
    echo.
) else (
    echo.
    echo ========================================
    echo Failed to add indexes
    echo ========================================
    echo.
)

pause
