Database Change Control, Part 3

In my previous posts, I have covered two forms of database change control. Both of those focused on taking some sort of schema and deploying it. But in this post, I am changing focus to something that stores the deltas and reapplies them. Both DbUp and Code-First Migrations will basically play a continual list of scripts.

With DbUp, you are starting with a list of scripts and applying those to the database. If you have to make a change to the database, you just make another script.

If we want to add some order tables to our database, we would just add more scripts:

006.CreateOrders.sql
007.CreateOrderLines.sql

To use DbUp, you just need to add a console application, do a little configuration, and you are off to the races.

1. Create a console application.

2. Add NuGet package “DbUp”.

3. Set up your program.cs to run dbup and have it perform your migrations.

4. Add a migration for TimeLogItems. Add it to a “Scripts” directory.

5. Write a simple table create script.

6. Make sure you mark the sql script as an embedded resource.

7. Run it.

The above steps will set up a project for running a database update. DbUp is my personal favorite way to manage database changes. It gives you all the power of full SQL, and it fits the model that I am most used to. Years ago, I worked at a company where we created a database migration system that worked a lot like DbUp. So DbUp feels like home to me.