@echo off
setlocal

if "%DATABASE_URL%"=="" (
  echo DATABASE_URL is required. Aborting.
  exit /b 1
)

echo Checking migration status...
call npm run db:migrate:status
if errorlevel 1 exit /b 1

echo Applying pending migrations...
call npm run db:migrate
if errorlevel 1 exit /b 1

echo Final migration status...
call npm run db:migrate:status
if errorlevel 1 exit /b 1

echo Done.
