title: How do I test database migrations?
body: <p>I'm using <a href="http://code.google.com/p/migratordotnet/" rel="noreferrer">Migrator.NET</a> to write database migrations for the application. Marc-André Cournoyer wrote:</p>
  
  <blockquote>
    <p>Like any code in your application you
    <em>must</em> test your migrations. Ups and downs code. Do it part of your
    continuous build process and test it
    on as many different databases and
    environment as you can.</p>
  </blockquote>
  
  <p>How do I do that? Say I have the Up() method which creates a table and the Down() method which drops the same table and I'm using SQL Server. How would a test look like? Should I be running SQL query against the system tables, like <code>select * from sys.columns</code>, to check if the table was created and that it has the proper structure? What if we're using NHibernate?</p>
  
  <p><strong>EDIT</strong>
  I mean migrations in the Rails ActiveRecord Migrations sense (creating, modifying and tearing down databases in small steps based on C# code).</p>
  
  <p><strong>EDIT 2</strong>
  And <a href="http://macournoyer.wordpress.com/2007/02/11/agile-database-fun-with-the-migrator/" rel="noreferrer">here</a>'s where I read about that we should test migrations. The blog post is actually linked from Migrator's wiki.</p>