Monday, 27 October 2008

Announcing SimpleScriptRunner - a very basic migrations tool

Just thought I'd share a very basic tool called SimpleScriptRunner. Its basically just something for running a directory of numbered SQL scripts against a SQL Server database for migrations, using the syntax

SimpleScriptRunner.exe <server> <database> <path to sql scripts>
I like to call it from a post build event in a VS project like so:
SimpleScriptRunner .\sqlexpress $(SolutionName)Db $(ProjectPath) 
If the database doesn't already exist, it will create it. The scripts are run in numerical order (you need to call them something like 0001 - First script.sql), and any scripts that have been already executed against the database are skipped*. 
I had been using MigratorDotNet for my migrations, and its probably a better tool as it can target databases other than SQL Server, but if you're using a lot of MS SQL Server, you might find this handy.
You can find it here on google code.
*actually if you modify the most recent script, it will re-execute it. This is a good thing when you are developing.

Submit this story to DotNetKicks