Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
FluentMigrator is a database migration framework for .NET written in C#. The basic idea is that you can create migrations which are simply classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them. Upon executing FluentMigrator, you tell it which version to migrate to and it will run all necessary migrations in order to bring your database up to that version.
How to use the FluentMigratorTask
There are four configuration options that are required to run a migration; the path to the console runner executable, the database provider, the target assembly and a connection string to the database.
An example of a migration to the latest version:
desc "FluentMigrator Test Runner Example" desc "MigrateDb" fluentmigrator :migrate do |migrator| migrator.command = 'lib/Migrate.exe' migrator.provider = 'postgres' migrator.target = './Migrations/bin/Release/Migrations.dll' migrator.connection = 'Server=127.0.0.1;Port=5432;Database=FluentMigrator;User Id=test;Password=test;' migrator.verbose = true end
You must provide the location of the FluentMigrator console runner executable either through the constructor or via the .command setting.
The kind of database you are migrating against. Available choices are: sqlserver2005, sqlserver2008, sqlserverce, sqlserver, mysql, postgres, oracle, sqlite, jet
The assembly containing the migrations you want to execute.
The connection string to the server and database you want to execute your migrations against.
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’.
Show the SQL statements generated and execution time in the console. Default is false.
Output generated SQL to a file. Default is no output (false). Use output_filename to control the filename, otherwise [assemblyname].sql is the default.
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 contains the migrations you want to run. Default is all migrations found within the Target Assembly will be run.
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.
The specific version to migrate. Default is 0, which will run all migrations.
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.
Displays the console runner’s help menu.
This task supports configuration via an external YAML file. For more information, see the yamlconfig page.
Command Line Options
This task supports additional command line options, including a
.parameters collection for passing in options that are not directly supported. For more information, see the commandline task options documentation.