@echo off setlocal EnableExtensions DisableDelayedExpansion if "%~1"=="" goto :usage if "%~2"=="" goto :usage if "%~3"=="" goto :usage set "SQL_SERVER=%~1" set "DATABASE=%~2" set "MODE=%~3" set "SQL_FILE=" set "V33_FILE=%~dp0..\fortucky-algorithm\src\main\resources\db\sqlserver\upgrade-shadow-v3-to-v33.sql" set "V34_FILE=%~dp0..\fortucky-algorithm\src\main\resources\db\sqlserver\upgrade-shadow-v33-to-v34.sql" if /I "%~3"=="upgrade" set "SQL_FILE=%~dp0..\fortucky-algorithm\src\main\resources\db\sqlserver\upgrade-shadow-v2-to-v3.sql" if /I "%~3"=="clean" set "SQL_FILE=%~dp0..\fortucky-algorithm\src\main\resources\db\sqlserver\install-shadow.sql" if /I "%~3"=="v33" set "SQL_FILE=%V33_FILE%" if /I "%~3"=="v34" set "SQL_FILE=%V34_FILE%" if not defined SQL_FILE (call :fail "mode must be upgrade, clean, v33 or v34" & exit /b 1) if not exist "%SQL_FILE%" (call :fail "SQL package file is missing" & exit /b 1) if not exist "%V33_FILE%" (call :fail "V3.3 SQL package file is missing" & exit /b 1) if not exist "%V34_FILE%" (call :fail "V3.4 SQL package file is missing" & exit /b 1) where sqlcmd >nul 2>nul if errorlevel 1 (call :fail "sqlcmd is not available on PATH" & exit /b 1) echo WARNING: stop the WMS shadow-enabled JVM and wait over 120 seconds first. echo Installing FT546WMS shadow package in %MODE% mode... sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -i "%SQL_FILE%" if errorlevel 1 exit /b 1 if /I "%MODE%"=="v33" goto :installed if /I "%MODE%"=="v34" goto :installed sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -i "%V33_FILE%" if errorlevel 1 exit /b 1 sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -i "%V34_FILE%" if errorlevel 1 exit /b 1 :installed echo INSTALL_OK mode=%MODE% exit /b 0 :usage echo Usage: %~nx0 SQL_SERVER DATABASE upgrade^|clean^|v33^|v34 1>&2 exit /b 2 :fail echo INSTALL_FAILED %~1 1>&2 exit /b 1