From 65308cb9108b381d55a46c194d27d2baa7266fd5 Mon Sep 17 00:00:00 2001 From: Seif Attar Date: Sat, 17 Sep 2011 04:24:04 +0100 Subject: [PATCH] Add deployment batch templates using custom create script --- db/SQLServer/TestRoundhousE/custom_db_create.sql | 5 +++++ .../templates/DBDeployment.DropCustomCreate.bat | 15 +++++++++++++++ .../DBDeployment.DropCustomFileCreate.bat | 14 ++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 db/SQLServer/TestRoundhousE/custom_db_create.sql create mode 100644 deployment/templates/DBDeployment.DropCustomCreate.bat create mode 100644 deployment/templates/DBDeployment.DropCustomFileCreate.bat diff --git a/db/SQLServer/TestRoundhousE/custom_db_create.sql b/db/SQLServer/TestRoundhousE/custom_db_create.sql new file mode 100644 index 00000000..29c82405 --- /dev/null +++ b/db/SQLServer/TestRoundhousE/custom_db_create.sql @@ -0,0 +1,5 @@ +USE master +IF NOT EXISTS(SELECT * FROM sys.databases WHERE [name] = '{{DatabaseName}}') +BEGIN + CREATE DATABASE {{DatabaseName}} +END \ No newline at end of file diff --git a/deployment/templates/DBDeployment.DropCustomCreate.bat b/deployment/templates/DBDeployment.DropCustomCreate.bat new file mode 100644 index 00000000..a6dd74b2 --- /dev/null +++ b/deployment/templates/DBDeployment.DropCustomCreate.bat @@ -0,0 +1,15 @@ +@echo off + +SET DIR=%~d0%~p0% + +SET database.name="${database.name}" +SET sql.files.directory="%DIR%${dirs.db}\SQLServer\${database.name}" +SET server.database="${server.database}" +SET repository.path="${repository.path}" +SET version.file="${file.version}" +SET version.xpath="//buildInfo/version" +SET environment=${environment} +SET custom.create.script="USE master;IF NOT EXISTS(SELECT * FROM sys.databases WHERE [name] = '{{DatabaseName}}')BEGIN; CREATE DATABASE {{DatabaseName}}; END;" + +"%DIR%Console\rh.exe" /d=%database.name% /f=%sql.files.directory% /s=%server.database% /vf=%version.file% /vx=%version.xpath% /r=%repository.path% /env=%environment% /drop +"%DIR%Console\rh.exe" /d=%database.name% /f=%sql.files.directory% /s=%server.database% /cds=%custom.create.script% /vf=%version.file% /vx=%version.xpath% /r=%repository.path% /env=%environment% /simple \ No newline at end of file diff --git a/deployment/templates/DBDeployment.DropCustomFileCreate.bat b/deployment/templates/DBDeployment.DropCustomFileCreate.bat new file mode 100644 index 00000000..239780e7 --- /dev/null +++ b/deployment/templates/DBDeployment.DropCustomFileCreate.bat @@ -0,0 +1,14 @@ +@echo off + +SET DIR=%~d0%~p0% + +SET database.name="${database.name}" +SET sql.files.directory="%DIR%${dirs.db}\SQLServer\${database.name}" +SET server.database="${server.database}" +SET repository.path="${repository.path}" +SET version.file="${file.version}" +SET version.xpath="//buildInfo/version" +SET environment=${environment} + +"%DIR%Console\rh.exe" /d=%database.name% /f=%sql.files.directory% /s=%server.database% /vf=%version.file% /vx=%version.xpath% /r=%repository.path% /env=%environment% /drop +"%DIR%Console\rh.exe" /d=%database.name% /f=%sql.files.directory% /s=%server.database% /cds=%sql.files.directory%\custom_db_create.sql /vf=%version.file% /vx=%version.xpath% /r=%repository.path% /env=%environment% /simple \ No newline at end of file