Database Updater is .NET application that helps you manage database updates and can be easily integrated with Cruise Control .NET.

For example,

<project name="ProjectName">
  ..
  <sourcecontrol type="svn">
  ...
  </sourcecontrol>
  <tasks>
    <exec>
      <executable>DatabaseUpdater.exe</executable>	
        <baseDirectory>[path to DatabaseUpdater installation folder]</baseDirectory>
        <buildArgs>-update</buildArgs>
        <buildTimeoutSeconds>360</buildTimeoutSeconds>
        <successExitCodes>0</successExitCodes>
    </exec>
    <nant>
    ...
    </nant>
  </tasks>
</project>


As you can see I specified only "0" as a success exit code. If Database Updater cannot execute one of the update scripts it will return exit code "2" and CCNET will stop deployment before the project will be compiled and published on the web.

To start using Database Updater you need to setup the database which means create a database schema and add information about the scripts that you probably already installed manually. Do not worry, Database Updater will do it for you. Just make a command:

DatabaseUpdater -setup -no_execute

"-setup" means adding database schema that needs Database Updater to work with database and "-no_execute" means add all scripts that you have without actually executing them.

But before this let's edit Database Updater configuration file - DatabaseUpdater.exe.config. Two things you should be considered - path to folder where you store update scripts (somewhere in the source control imported project folder) and connection string to the database.

After setupping Database Updater you can ask it to update the database by this command:

DatabaseUpdater -update

Or add Executable task in CCNET like I described above. The latest version of Database Updater with sources you can find here (release version placed in /bin/release folder inside the archive). Please notice also that Database Updater works with any database that .NET Framework supports. Enjoy the coding and let continuous integration do the other stuff!

Last edited Mar 22, 2008 at 12:41 AM by klalex, version 9