Skip to content
Henrik edited this page Aug 21, 2014 · 1 revision

FluentMigrator is a database migration framework for .NET written in C#.

desc "Migrate db to latest version"
fluentmigrator :migrate => [:build] do |cmd|
  cmd.command = "path/to/migrate"
  cmd.provider = "postgres"
  cmd.target = "path/to/migrations"
  cmd.connection = "Server=localhost;Port=5000;Database=Fluentm"
  cmd.verbose
end

Required Parameters

Command

The location of the console runner executable.

command = "path/to/migrate"

Provider

The kind of database you are migrating: sqlserver2005, sqlserver2008, sqlserverce, sqlserver, mysql, postgres, oracle, sqlite, jet

provider = "postgres"

Target

The assembly containing the migrations you want to execute.

target = "path/to/migrations"

Connection

The connection string to the server and database you want to execute your migrations against.

connection = "Server=localhost;Port=5000;Database=Fluentm"

Optional Parameters

Task

The task you want FluentMigrator to perform: migrate, migrate:up, migrate:down, rollback, rollback:toversion, rollback:all. The default is migrate.

task = "migrate"

Verbose

Show the SQL statements generated and execution time in the console.

verbose

Out & Out File

Output generated SQL to a file. Use the output filename to control the filename, otherwise <assemblyname>.sql is the default.

out
out_file = "path/to/generated/sql"

Namespace

The namespace that contains the migrations to run. The default is all the migrations found within the target assembly.

namespace = "Foo.Something"

Steps

The number of versions to rollback if the task is rollback. The default is 1.

steps = 10

Preview

Only output the SQL generated by the migration - do not execute it.

preview

Version

The specific version to migrate. The default is 0, which will run all migrations.

version = 99

Profile

The profile to run after executing migrations.

profile = "Whatever"

Timeout

Overrides the default SqlCommand timeout of 30 seconds.

timeout = 90

Script Directory

The directory to load SQL scripts specified by migrations from.

script_directory = "db/migrations"

Guidance

(none)

Clone this wiki locally