Command Line Runner Options
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:
Database | Identifier | Alternative identifier(s) |
---|---|---|
Microsoft SQL Server 2019 | SqlServer2016(1) | SqlServer |
Microsoft SQL Server 2017 | SqlServer2016(2) | SqlServer |
Microsoft SQL Server 2016 | SqlServer2016 | SqlServer |
Microsoft SQL Server 2014 | SqlServer2014 | SqlServer |
Microsoft SQL Server 2012 | SqlServer2012 | SqlServer |
Microsoft SQL Server 2008 | SqlServer2008 | SqlServer |
Microsoft SQL Server 2005 | SqlServer2005 | SqlServer |
Microsoft SQL Server 2000 | SqlServer2000 | SqlServer |
PostgreSQL | Postgres | PostgreSQL |
PostgreSQL 9.2 | Postgres92 | PostgreSQL92 |
PostgreSQL 10.0 | PostgreSQL10_0 | PostgreSQL |
PostgreSQL 11.0 | PostgreSQL11_0 | PostgreSQL |
MySQL 4 | MySql4 | MySql |
MySQL 5 | MySql5 | MySql, MariaDB |
Oracle | Oracle | |
Oracle (managed ADO.NET) | OracleManaged | Oracle |
Oracle (DotConnect ADO.NET) | OracleDotConnect | Oracle |
Microsoft JET Engine (Access) | Jet | |
SQLite | Sqlite | |
Firebird | Firebird | |
Amazon Redshift | Redshift | |
SAP Hana | Hana | |
DB2 | DB2 | |
DB2 iSeries | DB2 iSeries | DB2 |
- (1) All integration tests ran without error against an SQL Server 2019 using the SqlServer2016 dialect.
- (2) All integration tests ran without error against an SQL Server 2017 using the SqlServer2016 dialect.
- (3) Support for Microsoft SQL Server Compact Edition is being dropped due to Microsoft end-of-life support date passing.
- (4) Support for SAP SQL Anywhere is being dropped due to SAP not supporting a .NET Core / .NET 5 database driver.
--connectionString, --connection, --conn, -c=VALUE
(required, can be a 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 searches for it in this order:
- The specified config file via
--connectionStringConfigPath
](#cscp) parameter - Target assembly's config file
- Machine.config config file
--connectionStringConfigPath, --configPath=VALUE
The absolute 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 in the --connectionString
parameter documentation.
Note: --connectionStringConfigPath
uses absolute path, whereas --assembly
uses relative path.
--task, -t=VALUE
(optional)
The task you want FluentMigrator to perform. Available choices are:
migrate:up
migrate
(same as migrate:up)migrate:down
(used in conjunction with the--version
switch. Warning: if you don't supply--version
this will revert all migrations)rollback
(per default this rollbacks one step. Use the--steps
switch to rollback more steps)rollback:toversion
(used in conjunction 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.
--outputSemicolonDelimiter, --outsemdel, -osd
(optional)
SQL statements in output file are delimited with a semicolon.
--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 migration steps - do not execute them. Add the --verbose
switch to also see the SQL statements. 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.
--startVersion=VALUE
The specific version to start migrating from. Only used when NoConnection is true. Should therefore only be used when generating an output file. Default is 0
--noConnection
Indicates that migrations will be generated without consulting a target database. Should only be used when generating an output file.
--profile=VALUE
(optional)
The "profile":https://github.com/schambers/fluentmigrator/wiki/Profiles 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. See also --include-untagged
option.
--include-untagged:
Includes untagged migrations. By default, if you use --tag=VALUE
to filter migrations to be run based on tags, untagged migrations will be excluded.
--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.
--stopOnError
Pauses migration execution until the user input if any error occurred. Default is false.
--allow-breaking-changes
Allows execution of migrations marked as breaking changes. Default is false.
--strip-
Disables stripping of comments from executed SQL. Note the -
at the end of the command.
--help, -h, -?
Displays help menu.
--providerswitches=VALUE
Specify provider specific options, for instance:
- (Oracle)
QUOTEDIDENTIFIERS=TRUE
, which will quote identifiers always - (Firebird)
Force Quote=true
, which will quote identifiers always