30.06.2013 Views

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example: deploying to test<br />

117<br />

Chapter 4: Managing Deployments<br />

In this example, we have deployed to our development environment a WidgetDev<br />

database, using the method described earlier for deploying to a sandbox server using <strong>Red</strong><br />

<strong>Gate</strong> <strong>SQL</strong> Source Control.<br />

Changes have been made to the schema and data of the database, and these changes are<br />

committed to source control (in the scripts folder WidgetDevScripts of SVN). When<br />

development changes are sufficient to trigger a build, the database is to be deployed to the<br />

testing database, WidgetTest.<br />

Data synchronization may fail if the schemas are not identical, so the schema changes<br />

are deployed first. This example deploys the schema and static data of WidgetDev to the<br />

testing server WidgetTest, and creates reports as part of the build process. To automate<br />

the deployment, save the command lines shown in Listing 4-9 as a .bat file, and run it as<br />

part of the build process.<br />

cd C:\program files\subversion\bin<br />

svn checkout http:///WidgetDev<br />

"C:\Scripts\WidgetDevScripts"<br />

cd "C:\Program Files\<strong>Red</strong> <strong>Gate</strong>\<strong>SQL</strong> Compare 8"<br />

sqlcompare /scr1:"C:\Scripts\WidgetDevScripts" /db2:WidgetTest<br />

/o:Default<br />

/Report:"C:\SchemaDiffReport.html"<br />

/ReportType:Interactive<br />

/ScriptFile:"C:\SchemaSyncScript.sql"<br />

/sync<br />

cd "C:\Program Files\<strong>Red</strong> <strong>Gate</strong>\<strong>SQL</strong> Data Compare 8"<br />

sqldatacompare /scr1:"C:\Scripts\WidgetDevScripts" /db2:WidgetTest<br />

/o:Default<br />

/Exclude:table:WidgetPurchases<br />

/ScriptFile:"C:\DataSyncScript.sql"<br />

/sync /v > C:\DataDeploy.txt<br />

Listing 4-9: Automating deployment to the test environment.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!