-
Notifications
You must be signed in to change notification settings - Fork 0
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
The assembly containing the migrations you want to execute.
The kind of database you are migrating against. Available choices are:
- sqlserver2000
- sqlserver2005
- sqlserver2008
- sqlserver2012
- sqlserverce
- sqlserver
- mysql
- postgres
- oracle
- sqlite
- jet
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
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
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’.
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 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.
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.
The namespace that contains the migrations you want to run. Default is all migrations found within the Target Assembly will be run.
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.
The number of versions to rollback if the task is ‘rollback’. Default is 1.
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.
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.
The profile to run after executing migrations.
Overrides the default SqlCommand timeout of 30 seconds.
The directory to load SQL scripts specified by migrations from.
Filters migrations to be run based on tags. See Filter migrations run based on Tags
A string argument that can be used in a migration. See ApplicationContext: Passing parameters to Migrations
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.
Displays help menu.
- Getting FluentMigrator
- How to create a Migration
- Fluent Interface
- Migration Runners
- Use inbuilt database functions when setting the default value
- Sql Server Specific Extensions
- Raw Sql Helper for inserting data
- Auto Reversing Migrations
- Resharper File Template
- Transaction Modes for the Migration Runner
- ApplicationContext: Passing parameters to Migrations
- Dealing with Multiple Database Types
- Filter migrations run based on Tags
- Enforce migration version numbering rules
- Create custom metadata for the VersionInfo table