SQL Databases and Version Control–Part 2

I originally wrote this as a code walkthrough but the code is fairly self explanatory and there is not much of it so I gave posted it on CodePlex http://sdbvc.codeplex.com/ under the MIT license (which basically allows anyone to do anything with it except sue me for it not working).

DBManager

DbManager

DbManager has one public method with two overloads. It upgrades a database either from an array of scripts or from a folder of scripts. The actual running of the scripts is done by an implementation of IScriptRunner.

IScriptRunner

IScriptRunner

The ScriptRunner only has one public method which executes a single script against a target database. Before it runs the script, it checks the script version against the database version using properties of an implementation of IVersionedDatabase.

IVersionedDatabase

IVersionedDatabase

The VersionedDatabase exposes properties for version numbers which it retrieves from the schemachangelog table and is the class that finally executes the scripts against the target database.

Leave a Reply