views:

1954

answers:

10

I was once under the belief that Microsoft was working on an official, ruby-like, Migration framework. However, I haven't been able to find any additional information (or even the original source of my belief).

Does anyone know any information about an official migration framework? or possibly an open source one?

+1  A: 

@Ryan: No, not IronRuby...I was under the belief that this was language agnostic.

Karl Seguin
A: 

It's not from MS, but The Castle Project aims to bring a lot of Rails functionality to the CLR languages. A sub-project of this is a migration engine. I have not used it so I can not recommend it, but it exists.

Justin Walgran
+1  A: 

You might find the MultiFunctionMachine project useful.

The entry on how to get started with migrations is here. This looks promising:

using System;
using System.Collections.Generic;
using Machine.Migrations;

public class CreateUserTable : SimpleMigration
{
public override void Up()
{
Schema.AddTable("users", new Column[] {
new Column("Id", typeof(Int32), 4, true, false),
new Column("Name", typeof (string), 64, false, false),
new Column("Email", typeof (string), 64, false, false),
new Column("Login", typeof (string), 64, false, false),
new Column("Password", typeof (string), 64, false, false),
});
}

public override void Down()
{
Schema.DropTable("users");
}
}
Brett Veenstra
+1  A: 

There is some amount of support for migrations in the open source project Subsonic, but that's not from Microsoft even if the project owner now works for them. Us, rather.

As one of the devs on IronRuby, I can say with certainty that the IronRuby project isn't working on anything like this -- why should we, when you can already get migrations directly through ActiveRecord? :)

Curt Hagenlocher
+45  A: 

This .NET Database Migration Tool Roundup provides a good rundown of the options.

The options listed are:

  • Rails Migrations running on SQL Server
  • RikMigrations
  • Tarantino
  • Migrator.NET
  • Machine Migrations
  • Subsonic Migrations
  • dbDeploy.NET
Andrew Peters
should be marked as the answer ... its exactly what i needed
Michal
Yep, unfortunately this happens all the time on SO :-/
Andrew Peters
RoundhousE is a new kid on the block that hopes to accomplish more with migrations. http://projectroundhouse.org There are some articles over at ferventcoder.com showcasing what it can do.
ferventcoder
+5  A: 

Another alternative is the Migrator.Net project (at time of writing it is in version 0.7). You write migration classes with the following syntax:

using Migrator.Framework;
using System.Data;

namespace DBMigration
{
    [Migration(20080401110402)]
    public class 001_CreateUserTable : Migration
    {
        public void Up()
        {
            Database.CreateTable("User",
                    new Column("UserId", DBType.Int32, ColumnProperties.PrimaryKeyWithIdentity),
                    new Column("Username", DBType.AnsiString, 25)
                );
        }

        public void Down()
        {
                Database.RemoveTable("User");
        }
    }
}

…and the migration classes run in a sequential order in a MSBuild or NAnt script.

Spoike
A: 

In case you're still interested, I've just released Alpha 1 of octalforty Wizardby, a database migration framework.

Anton Gogolev
It's more concise in the long run, it's platform-independent, it allows for extensibility (see Refactoring stuff) and for some optimizations (type-inference, automatic naming of indexes/constraints).
Anton Gogolev
Sure I get the advantages of using a DSL, its just Migrations never struck me as the best place to use one -I struggle how a DSL helps here, I cannot infer how to do anything by using intellisence - i have to learn your whole DSL to do anything.
Dan
Had alook at your framework - works quite nicely - any support for migrating content?
Dan
Yep, I have plans for implementing a so-called "import-data" "refactoring" to actually import data from a, say, CSV file. Migrating existing data is harder, but I think I will handle it eventually.
Anton Gogolev
+1  A: 

Iv used Migrator.NET 0.8 and Subsonic 2.1, which are supposed to be two of the best and neither is robust enough to to be used for anything serious at the moment. Both require you to tweak the source code to even get relatively simple things migrating.

Dan
Can you elaborate on this?
Anton Gogolev
I would be interested in your experiences also.
Jason Short
+2  A: 

My consulting company is using Migrator.NET for a handful of .NET projects in production. One of my colleagues committed some substantial enhancements back to the project to make it more production ready. There's definitely still room for improvement in it, but it was the best of the bunch when we made our choice a year ago.

Dan Tanner
A: 

There is a new kid on the block named RoundhousE. Basically some of the same idioms as Tarantino where you write regular SQL scripts (some companies like ours are into that).

You provide RoundhousE a folder with the folders:

  • Up
  • Down (at some point)
  • Functions
  • Views
  • Sprocs
  • Permissions

and it will execute everything in those folders. The items in the Up folder are only executed one time. That is where you put DDL/DML changes. Everything else will execute every time that RoundhousE executes against that directory. Did I mention you could override each of those folders with your own naming scheme (like to use a folder called Update instead of Up)?

We also version the database based on the version of the repository so that it makes it easy to determine where the database is in relation to the source code (and we allow for multiple repositories to version the database).

Works with NAnt, MSBuild, and soon will have a standalone console app (so it will work with any deployment system).

ferventcoder