Database Schema Version Control Tool

It is essential to treat database schema as source code and apply all the norms and best practices applicable to it. From what I hear and read, database schema version control is non-existent in too many projects.

Various techniques to accomplish version control of database schemas have been discussed and published. Martin Fowler and Pramod Sadagale has written a comprehensive article on Evolutionary Database Design. It is a must-read for everyone involved with database development.

K. Scott Allen writes in detail about an excellent system here – Versioning Databases – Change Scripts. This approach is sufficiently light-weight (for my taste) and provides complete control over the whole process.

I am providing a free tool here that you can use to implement this system. It will even create the SchemaVersionsLog table for your database, if it doesn’t exist. If you are using this tool with MSSQL Server, you can get started with very little effort. If you are using a different DBMS, you can still use this tool. It uses NHibernate to access the SchemaVersionsLog table. So, any DBMS supported by NHibernate is acceptable, as long as it comes with a command line tool to execute the sql scripts.

Download DbUpdater here.

Related posts

This entry was posted in C#, database, freeware, sql, version-control and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Adrian Hara
    Posted June 25, 2008 at 1:43 am | Permalink

    Hello,

    I’ve tried the tool and it runs forever after it says “executing baseline.sql”. I’m running it against a sql2000 server and a 400kb baseline.sql.

    Any ideas why?

    Thanks

  2. Chris Bjugstad
    Posted July 11, 2008 at 6:01 am | Permalink

    Interesting tool…I’m trying to implement this at my current employer and would be interested in seeing the source code (if you are willing to share). I’m trying to get dba buy-in on the process and it would be helpful to articulate everything that is going to be done to the db.

  3. Cory
    Posted September 15, 2008 at 11:46 am | Permalink

    We’re trying to use your DbUpdater, but when I have indexes and foreign keys scripted in our baseline.sql file, the exe hangs.

    The baseline.sql file runs perfectly fine in SQL Management Studio. DbUpdater will work if I remove all the indexes and foreign keys from baseline.sql and move them to post.X.sql scripts.

    We’ve also noticed that if you only have 1 db changes file, DbUpdater will not recognize that there are any changes. We have had to create 2 db changes files before the DbUpdater would notice the updates.

  4. Posted September 20, 2008 at 11:58 pm | Permalink

    DbUpdater version 1.4 fixes two bugs -
    1. If you only have 1 db changes file, DbUpdater will not recognize that there are any changes.
    2. When you have indexes and foreign keys scripted in our baseline.sql file, the exe hangs.

    Adrian and Cory, Thanks for your feedback.

  5. Posted July 7, 2010 at 2:35 pm | Permalink

    Hi there!
    Some months ago I searched tool for versioning MySQL schema. I found many useful tools, like Doctrine migration, RoR migration, some tools writen in Java and Python.

    But no one of them was satisfied my requirements.

    My requirements:

    1. No requirements , exclude PHP and MySQL
    2. No schema configuration files, like schema.yml in Doctrine
    3. Able to read current schema from connection and create new migration script, than represent identical schema in other installations of application.

    I started to write my migration tool, and today I have beta version.

    Please, try it, if you have an interest in this topic.
    Please send me future requests and bugreports.

    Source code: bitbucket.org/idler/mmp/src
    Overview in English: bitbucket.org/idler/mmp/wiki/Home
    Overview in Russian: antonoff.info/development/mysql-migration-with-php-project

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Twitter Updates

  • Notes

    Using DbUpdater with MySql
    DbUpdater can be used with mysql. Here are the files you need to jumpstart the integration – DbUpdater-MySql.zip 1. You might need to change the path to mysql.exe in mysql-exec.bat. 2. Modify values in mysql-sample-command-line.bat. Make sure mysql.data.dll is placed in GAC or in the same directory as DbUpdater.exe. Connector binaries can be downloaded from here - http://dev.mysql.com/downloads/connector/net/6.1.html (0)

    Online Backup Solution
    Finalized online backup solution : JungleDisk. I can run it on all of my machines without paying extra. I get to keep the ownership of my data – by using my own Amazon S3 storage. Backed up all family photos – all 30 GBs. Feeling good (0)

    Switched to Thematic
    I have switched to Thematic theme on this blog over the weekend. I created a child theme after playing around with the customization hooks. I added a widgetized area below main asides, did some css modifications and created a three column, flexible layout just the way I wanted. I am so glad I switched to Thematic. ThemeShaper forums are very helpful. These articles were just what I needed to get started : How to make a child theme for WordPress and How I used a WordPress Child Theme To Redesign My Blog. (0)

  • BookShelf

    Planned books:

    • ASP.NET MVC in Action

      ASP.NET MVC in Action by Jeffrey Palermo, Ben Scheirman, Jimmy Bogard

    Current books:

    • Pragmatic Thinking and Learning: Refactor Your Wetware (Pragmatic Programmers)

      Pragmatic Thinking and Learning: Refactor Your Wetware (Pragmatic Programmers) by Andy Hunt

    • Working Effectively with Legacy Code

      Working Effectively with Legacy Code by Michael Feathers

    Recent books:

    • How I Got Published: Famous Authors Tell You in Their Own Words

      How I Got Published: Famous Authors Tell You in Their Own Words by Ray White

    • Pro WPF: Windows Presentation Foundation in .NET 3.0

      Pro WPF: Windows Presentation Foundation in .NET 3.0 by Matthew MacDonald

    • Programming Windows Presentation Foundation

      Programming Windows Presentation Foundation by Chris Sells, Ian Griffiths

    • Advanced MVVM

      Advanced MVVM by Josh Smith

    View full Library

Close
E-mail It