@echo off
echo  =========================
echo  REPORTING DATABASE UPDATE
echo  =========================

IF "%DEPLOY_TOOL_HOME%"=="" (
	echo > DEPLOY_TOOL_HOME must be defined
	exit/B
)

IF "%JBOSS_HOME%"=="" (
	echo > JBOSS_HOME must be defined
	exit/B
)

echo copy sql update files
copy %DEPLOY_TOOL_HOME%\DBupdate\. %DEPLOY_TOOL_HOME%\sql
echo  - Run database update
java -jar %DEPLOY_TOOL_HOME%\bin\install-reports.jar
if %ERRORLEVEL% EQU 1 (
	echo  - Error detected, check install.log file
) else (
	echo  - Database update run successfully
)

echo clearing sql folder contents
del %DEPLOY_TOOL_HOME%\sql\* /Q

echo  ==========================
echo  END OF DATABASE UPDATE
echo  ==========================

pause

exit/B