Skip to content

Command Line Runner Options

daniellee edited this page Dec 7, 2012 · 24 revisions

Migrate.exe can be called with the following parameters. The first three parameters are required if running a migration.
A lot of the parameters have more than one switch for the same parameter. If a parameter has an = sign after it, then it expects some text value to be set, otherwise it is just a boolean switch e.g. the preview parameter. When writing the command, the = sign is optional (e.g. --task=migrate or --task migrate). Single dashes or double dashes is also optional e.g. -task or --task.

Examples:


Migrate.exe /conn "Data Source=db\db.sqlite;Version=3;" /provider sqlite /assembly your.migrations.dll /verbose


migrate --conn "server=.\SQLEXPRESS;uid=testfm;pwd=test;Trusted_Connection=yes;database=FluentMigrator" --provider sqlserver2008 --assembly "..\Migrations\bin\Debug\Migrations.dll" --task migrate --output --outputFilename migrated.sql


migrate -c "server=.\SQLEXPRESS;uid=testfm;pwd=test;Trusted_Connection=yes;database=FluentMigrator" -db sqlserver2008 -a "..\Migrations\bin\Debug\Migrations.dll" -t migrate -o -of migrated.sql

--assembly, -a, --target=VALUE (required)

The assembly containing the migrations you want to execute.

--provider, --dbtype, --db=VALUE (required)

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

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

--connectionString, --connection, --conn, -c=VALUE (required or connectionStringName)

The connection string to the server and database you want to execute your migrations against. This can be a full connection string or the name of the connection string stored in a config file.

When specifying a named connection string, FluentMigrator searchs for it in this order:

1. The specified config file via --connectionStringConfigPath parameter
2. Target assembly’s config file
3. Machine.config config file

--connectionStringConfigPath, --configPath=VALUE

The path of the config file where the connection string named by is found. If not specified, it defaults to lookup order specified --connectionString parameter documentation

--task, -t=VALUE (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
  • listmigrations

Default is ‘migrate’.

--verbose=VALUE (optional)

Show the SQL statements generated and execution time in the console. Default is false. This should be a boolean switch but is not. VALUE can be anything to set to true and the switch should not be specified to set it to false. For example, —verbose qwerty would set it to true.

--output, --out, -o (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 does not take a value.

--outputFilename, --outfile, --of=VALUE (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, --ns=VALUE (optional)

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

--nested (optional)

Whether migrations in nested namespaces should be included. Used in conjunction with the namespace option. The default is false so that nested namespaces are not included. This is a boolean switch so it does not take a value.

--steps=VALUE (optional)

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

--preview, -p (optional)

Only output the SQL generated by the migration – do not execute it. Default is false. This is a boolean switch so it does not take a value.

--version=VALUE (optional)

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

--profile=VALUE (optional)

The profile to run after executing migrations.

--timeout=VALUE (optional)

Overrides the default SqlCommand timeout of 30 seconds.

--workingdirectory, --wd=VALUE (optional)

The directory to load SQL scripts specified by migrations from.

--tag=VALUE

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

--context=VALUE

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

--help, -h, -?

Displays help menu.

Clone this wiki locally