Skip to content

Command Line Runner Options

Daniel Lee edited this page Sep 22, 2013 · 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. This parameter is used together with the --connectionString parameter, the --connectionString parameter specifies the name of the connection string in the config file. If the config file looks like this:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <clear />
    <add name="SRVConnectionString" connectionString="server=SQLEXPRESS;uid=test;pwd=test;database=FluentMigrator"/>
  </connectionStrings>
</configuration>

Then the --connectionString parameter should be set to SRVConnectionString.

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 (per default this rollbacks one step. Use the --steps switch to rollback more steps)
  • rollback:toversion (used in conjuction with the --version switch. Will rollback all versions down to the specified version, not including the specified version. The Migration attribute contains the version that should be used with the --version switch.)
  • 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. The version of a migration is the unique identifier that is contained in the Migration attribute. For example, if a Migration has this attribute [Migration(201303062126)] then the version is 201303062126.

--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

--transaction-per-session, --tps (optional)

The default transaction is one transaction per migration so the default for this switch is false. Run migrations in one transaction per session (task) instead. This is a boolean switch so it does not take a value.

--help, -h, -?

Displays help menu.

Clone this wiki locally