This project is read-only.

Project Setup

File Structure

DBUpdater works by recursing through all directories in a given directory. When recursing it is looking for this 'structure'.
  1. A directory named 'SQL'.
  2. The SQL directory must contain a directory named, 'ChangeScripts'.
  3. The SQL directory must also contain a file named, 'DatabaseInstanceNamePrefix.txt'.

When it finds this 'structure' it will load up all scripts in the 'ChangeScripts' directory (you can have any number of sub directories within ChangeScripts, DBUpdater will go through all sub directories. You can also safely change the location of the scripts within that directory as all DBUpdater cares about is the name of the file.)

Make sure you put the name of the database that is to be updated in the DatabaseInstanceNamePrefix.txt file. Note that the name you enter should be the database instance name found in the app.config file (minus the environment name), not necessarily a match on the name of the database. See the DBUpdater.Tests project for a simple example.

You can only put scripts for ONE database in this ChangeScripts directory.

It's not necessary but it's a good idea to 'include' all files in this structure in your project files. Just makes it all more visible.

It is possible (but currently in a hard coded manner) to tell DBUpdater to ignore certain files. Currently it ignores 'scc', 'vssscc' and 'resharperoptions' files. It is also possible to tell it to ignore (also in a hard coded manner) certain directories. Currently it ignores '_svn' directories.

Multiple Databases

DBUpdater has been designed to allow updates to multiple databases.

So if you create the above 'structure' in multiple projects, each with a difference Database Instance Name Prefix, DBUpdater find all of them and run all the scripts against their appropriate database. Importantly it will do this within a 'cross database' transaction so if any of the scripts fails, all changes in all databases will be rolled back. (this implementation was done in .Net 1.1 and so is my own version, I know there is a TransactionManager since 2.0 but I've not used it and well, my version works fine...

Last edited May 25, 2008 at 8:53 AM by wallism, version 5


No comments yet.