5

I'm looking at versioning databases and came across the usual articles regarding how to do this (coding horror, ode to code, etc). This all make perfect sense to me, however I'm trying to find a script runner that will run the sql scripts for me. All these articles mention having something to run them automatically, but none of them make any recommendations.

Does anybody know of any utilities for running these scripts? Ideally something that works in the following way:

  1. Runs everything in a transaction so if any single update fails, the whole thing fails
  2. I have control over the name of the scheme version database table
  3. Ability to have a series of scripts that are always run if an upgrade takes place
  4. Can be run as part of an automated task

    EDIT

  5. Open Source

Montag451
  • 1,168
  • 3
  • 14
  • 30
Matt Brailsford
  • 2,209
  • 3
  • 28
  • 40
  • DDL is usually disallowed within a transaction, so for this type of thing you generally want to do a backup first, then apply your versioning change scripts, and on error, restore the backup. – Samuel Neff Dec 23 '09 at 21:32
  • PS Can anybody sugest a better heading for this question? – Matt Brailsford Dec 23 '09 at 21:33
  • @Sam I guess the transaction thing isn't a must have then, as long as there is a mechanism to return the datbase back to it's original state should something fail, and do it automaticaly. – Matt Brailsford Dec 23 '09 at 21:36
  • 1
    Matt, you might want to check out migrations frameworks. http://flux88.com/blog/net-database-migration-tool-roundup/ covers a bunch of .NET frameworks, and there are plenty of others out there for other environments (e.g. Rails). – itowlson Dec 23 '09 at 21:42

2 Answers2

7

We Use DbUp as Script Runner in our Web Project. Its simple and nice open source tools that help you to write you own script runner with Console Application fashion.

DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been run already, and runs the change scripts that are needed to get your database up to date.

we can run scripts from folder in filesystem or you can embed them to your assembly and run them as embedded scripts.

you can find more information and sample on their code repository on github.

http://dbup.github.com

Navid
  • 459
  • 6
  • 17
5

Check out SSW SQL Deploy - it would appear to do just about all you're asking for. It keeps track of already executed scripts, it'll run a whole batch of scripts at once and on multiple servers (if required), and so forth.

alt text

It's a pretty simple, but nifty tool - highly recommended!

Community
  • 1
  • 1
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459