Skip to content

Nant Runner Options

daniellee edited this page Jul 18, 2012 · 8 revisions

The Nant task for FluentMigrator is a way to run migrations from Nant build scripts and is very similar to the Command Line Runner Options.

Example:


<?xml version="1.0" encoding="UTF-8" ?>
<project name="fluentmigrator" xmlns="http://nant.sf.net/release/0.85/nant.xsd" default="migrate">
	<loadtasks assembly="packages/FluentMigrator.1.0.2.0/tools/FluentMigrator.NAnt.dll" />

	<target name="migrate" description="Migrate the database to the latest version">
	  	<migrate
	    		database="sqlserver2008"
	    		connection="server=.\SQLEXPRESS;uid=testfm;pwd=test;Trusted_Connection=yes;database=FluentMigrator"
	    		target="./Migrations/bin/Debug/Migrations.dll"
			output="True"
	    		outputfilename="generated.sql"
		/>
	</target>
	
	<target name="migrate-rollback-all" description="Migrates the database back to original state prior to applying migrations">
	  	<migrate
	    		database="sqlserver2008"
	    		connection="server=.\SQLEXPRESS;uid=testfm;pwd=test;Trusted_Connection=yes;database=FluentMigrator"
	    		target="./Migrations/bin/Debug/Migrations.dll"
			task="rollback:all"
		/>
	</target>

</project>

target (required)

The assembly containing the migrations you want to execute.

database (required)

The kind of database you are migrating against. Available choices are:

  • sqlserver2000
  • sqlserver2005
  • sqlserver2008
  • sqlserverce
  • sqlserver
  • mysql
  • postgres
  • oracle
  • sqlite
  • jet

connection (required)

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

task (optional)

The task you want FluentMigrator to perform. Available choices are:

  • migrate:up
  • migrate (same as migrate:up)
  • migrate:down
  • rollback
  • rollback:toversion
  • rollback:all

Default is ‘migrate’.

verbose (optional)

Show the SQL statements generated and execution time in the console. Default is false. This is a boolean switch so it can be set to "true" or "false".

output (optional)

Output generated SQL to a file. Default is no output. Use outputFilename to control the filename, otherwise [assemblyname].sql is the default. This is a boolean switch so it can be set to "true" or "false".

outputfilename (optional)

The name of the file to output the generated SQL to. The output option must be included for output to be saved to the file.

namespace (optional)

The namespace contains the migrations you want to run. Default is all migrations found within the Target Assembly will be run.

steps (optional)

The number of versions to rollback if the task is ‘rollback’. Default is 1.

preview (optional)

Only output the SQL generated by the migration – do not execute it. Default is false. This is a boolean switch so it can be set to "true" or "false".

to (optional)

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

profile (optional)

The profile to run after executing migrations.

timeout (optional)

Overrides the default SqlCommand timeout of 30 seconds.

workingdirectory (optional)

The directory to load SQL scripts specified by migrations from.

tags (optional)

Filters migrations to be run based on tags. See Filter migrations run based on Tags

context (optional)

A string argument that can be used in a migration. See ApplicationContext: Passing parameters to Migrations

Clone this wiki locally