Announcing RikMigrations

by Richard Mason 22. November 2007 04:45

Over the last couple of weeks I've been working on a migrations framework for .NET called RikMigrations. There's a couple of existing frameworks but they're mostly integrated in other large projects like SubSonic or didn't quite fit my needs/wants.

RikMigrations is currently relatively small and simple, but I am releasing it under a BSD license on CodePlex so others can jump on board and build it up. Check out the project homepage at http://www.rikware.com/RikMigrations.html to find out more, including a simple tutorial demonstrating its use. 

kick it on DotNetKicks.com

Comments (10) -

11/23/2007 7:58:14 PM #

I'm interested to know what didn't fit your needs in the Migrator.NET project, which many people use including myself. This project currently supports MSSQL, MySQL and PostgreSQL.

http://code.google.com/p/migratordotnet/

Jonathon Rossi

11/24/2007 3:36:12 AM #

Migrator.NET was one of the projects I checked out. I didn't find any major problems with it but I couldn't find much in the way of documentation and the project didn't seem to have much activity. I considered contributing to it, but figured if I needed to do much work it would take me too long to understand Migrator.NET without doco. I think the best move would be to work up some tutorials for Migrator.NET showing off its features.

Richard Mason

11/24/2007 4:27:42 AM #

I actually considered building my own migrator ages ago because Migrator.NET seemed dead. Only recently Migrator.NET has been moved to google code because Marc-André Cournoyer has permanently become a rails convert.

macournoyer.wordpress.com/.../

I know a few blog posts doesn't count as documentation and agree that a few tutorials would make it easier for people to get started. However, these blog posts tell you just about everything you need to know to use it, the oldest one in particular:

http://macournoyer.wordpress.com/?s=migrator

Jonathon Rossi

11/24/2007 5:05:17 AM #

Thanks. I hadn't found those posts. It would be good if they were linked to off the google code page.

I still haven't seen how to set up foreign keys in Migrator.NET. The code seems to have some foreign key support but I haven't dived deep enough to work it out myself. I tried to pick it up from the SchemaDumper class but it doesn't seem to support them.

Admittedly RikMigrations is short of doco as well, but I plan on leaking that out over the next couple of weeks as I find time. I think it will be good to have multiple projects in the short term anyway to drive development a bit. It'll also be interesting to see what comes out of the SubSonic miration support, however I think I'll still prefer RikMigrations or Migrator.NET since I can use them on their own without adopting the rest of SubSonic.

Richard Mason

11/24/2007 6:45:50 AM #

I have requested for those links to be added to the google code project home page.

You are right that the SchemaDumper only supports tables and columns.

You can create a foreign key using the GenerateForeignKey or AddForeignKey methods, the first one will generate a name for you.

Example:
Database.GenerateForeignKey("Orders", "CustomerId", "Customers", "CustomerId", ForeignKeyConstraint.Cascade);

One cool thing with Migrator.NET which you might like to implement is DDL transactions. Migrator.NET provides transaction support for SQL Server and PostgreSQL, because MySQL doesn't have transactions for DDL.

Good luck with RikMigrations, it is always good to have different OSS projects that have a different or the same focus. I'll be watching this space to see how RikMigrations evolves.

Jonathon Rossi

11/26/2007 6:56:13 PM #

We found Migrator.Net VERY useful and are using it in our Migrations strategy. I developed a Windows Forms app to display the migrations and it's working great so far. Transactions feature are really cool although I am not sure how you can successfully rollback data migrations. We are not using the down feature of Migrations.

Good luck with RikMigrations.

Rams

11/26/2007 7:59:32 PM #

Frederico

I found your migrations implementation today and I'm giving it a go.

It seems simple and expressive, but I'm struggling with some issues, that you will probably clear out when you start rolling out documentation.

But damn, am I impatient...

Could you do a quick blog to show multiple related migrations? I can't do this:

[assembly: Migration(typeof(MyMigrations), 1)]
public class FirstMigration : IMigration

.
.
.

[assembly: Migration(typeof(MyMigrations), 2)]
public class SecondMigration : IMigration

How do I code these two migrations to be sequential, so that when i go...

MigrationManager.UpgradeMax(typeof(MyMigrations).Assembly);

...the two get executed?

Frederico

11/27/2007 1:55:09 AM #

Hi Frederico,

You need to specify the type of each migration in the attributes. So in your case you'd have these two attributes:

[assembly: Migration(typeof(FirstMigration), 1)]
[assembly: Migration(typeof(SecondMigration), 2)]

Then for UpgradeMax you just need the assembly so you can choose any type in the assembly:

MigrationManager.UpgradeMax(typeof(FirstMigration).Assembly);

I've released a couple of more info pages a couple of days ago. I also checked in some changes yesterday to support more column types so you may wish to grab those off codeplex.

Richard Mason

4/9/2008 7:34:16 AM #

Just tried out some simple migrations and really nice work, I am very excited to start using this with my .Net work!  Exact right decision to not have this linked to another framework or larger project, just what I was looking for.

Dan Pisarski

4/10/2010 10:46:50 PM #

John

That's really good!

John

Comments are closed

About Us

RikWare is a software development company based in Brisbane, Australia. Led by director, Richard Mason, RikWare focusses on solving challenging business problems promptly and effectively.

RikWare is also the owner of Aussie Bushwalking, a free, wiki-like collaboration site for bushwalkers and the creator of RikMigrations, a migration framework for .NET.

Aussie Bushwalking

Want to discover some new bushwalking ideas? Share a few of your own? Aussie Bushwalking is like Wikipedia... but for bushwalkers. Head on over. Anybody can see the walks and it's free to sign up and share your own.

 

RikMigrations

RikMigrations is a database migration library for .NET based on the migrations facility provided by Ruby on Rails. It allows simple upgrading and downgrading of databases using .NET code (such as VB or C#) either from the command line or built into your application. Unlike many other migration frameworks, RikMigrations is a stand-alone library which does not rely on a large surrounding framework.