Skip to content
fluent migrations for .net
C#
Pull request Compare This branch is 53 commits behind enkari:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
src
tools
.gitignore
FluentMigrator.msbuild
FluentMigrator.sln
FluentMigratorVS2008.sln
README.textile
Rakefile
build.bat

README.textile

FluentMigrator

Fluent migrations for .NET!

Project Info

Getting started with the example project

The example project is a class library that contains the migrations, and a rakefile to wrap the Migrator.Console.exe calls.
You will need ruby, rubygems and the rake gem installed. Instructions to do this can be found here

Run

rake compile
from the command line in the projects root directory. This will
compile the application and copy the required files over to the example project
src/FluentMigrator.Example/tools/FluentMigrator. cd into the example project and compile it:

cd src\FluentMigrator.Example

rake

rake -T

This will list the available commands

rake clean
rake compile
rake db:delete
rake db:migrate
rake db:migrate:up
rake db:migrate:down
rake db:rollback

The db:migrate commands can take an optional VERSION parameter

rake db:migrate VERSION=20090906205342

db:rollback can take an optional STEPS parameter.

rake db:rollback STEPS=2

Example Migration


[Migration(1)]
public class TestCreateAndDropTableMigration: Migration
{
	public override void Up()
	{
		Create.Table("TestTable")
			.WithColumn("Id").AsInt32().NotNullable().PrimaryKey().Identity()
			.WithColumn("Name").AsString(255).NotNullable().WithDefaultValue("Anonymous");

		Create.Table("TestTable2")
			.WithColumn("Id").AsInt32().NotNullable().PrimaryKey().Identity()
			.WithColumn("Name").AsString(255).Nullable()
			.WithColumn("TestTableId").AsInt32().NotNullable();

		Create.Index("ix_Name").OnTable("TestTable2").OnColumn("Name").Ascending()
			.WithOptions().NonClustered();

		Create.Column("Name2").OnTable("TestTable2").AsBoolean().Nullable();

		Create.ForeignKey("fk_TestTable2_TestTableId_TestTable_Id")
			.FromTable("TestTable2").ForeignColumn("TestTableId")
			.ToTable("TestTable").PrimaryColumn("Id");

		Insert.IntoTable("TestTable").Row(new { Name = "Test" });
	}

	public override void Down()
	{
		Delete.Table("TestTable2");
		Delete.Table("TestTable");
	}
}

Example usage of console runner

tools\fluentmigrator\FluentMigrator.Console.exe /connection "Data Source=db\db.sqlite;Version=3;" /db sqlite /target build\Migrations.dll
Something went wrong with that request. Please try again.