Class MigrationRunner
The default IMigrationRunner implementation
Inherited Members
Namespace: FluentMigrator.Runner
Assembly: FluentMigrator.Runner.dll
Syntax
public class MigrationRunner : IMigrationRunner, IMigrationScopeStarter
Constructors
| Edit this page View SourceMigrationRunner(IAssemblyCollection, IRunnerContext, IMigrationProcessor, IVersionTableMetaData, IMigrationRunnerConventions)
Initializes a new instance of the MigrationRunner class.
Declaration
[Obsolete]
public MigrationRunner(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData = null, IMigrationRunnerConventions migrationRunnerConventions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IAssemblyCollection | assemblies | The collection of assemblies to scan for migrations, etc... |
| IRunnerContext | runnerContext | The runner context |
| IMigrationProcessor | processor | The migration processor |
| IVersionTableMetaData | versionTableMetaData | The version table metadata |
| IMigrationRunnerConventions | migrationRunnerConventions | The custom migration runner conventions |
MigrationRunner(IAssemblyCollection, IRunnerContext, IMigrationProcessor, IVersionTableMetaData, IMigrationRunnerConventions, IConventionSet, IMigrationScopeManager)
Initializes a new instance of the MigrationRunner class.
Declaration
[Obsolete]
public MigrationRunner(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData, IMigrationRunnerConventions migrationRunnerConventions, IConventionSet conventionSet, IMigrationScopeManager migrationScopeHandler = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IAssemblyCollection | assemblies | The collection of assemblies to scan for migrations, etc... |
| IRunnerContext | runnerContext | The runner context |
| IMigrationProcessor | processor | The migration processor |
| IVersionTableMetaData | versionTableMetaData | The version table metadata |
| IMigrationRunnerConventions | migrationRunnerConventions | The custom migration runner conventions |
| IConventionSet | conventionSet | The expression convention set |
| IMigrationScopeManager | migrationScopeHandler | The migration scope handler |
MigrationRunner(IOptions<RunnerOptions>, IOptionsSnapshot<ProcessorOptions>, IProfileLoader, IProcessorAccessor, IMaintenanceLoader, IMigrationInformationLoader, ILogger<MigrationRunner>, IStopWatch, IMigrationRunnerConventionsAccessor, IAssemblySource, MigrationValidator, IServiceProvider)
Initializes a new instance of the MigrationRunner class.
Declaration
public MigrationRunner(IOptions<RunnerOptions> options, IOptionsSnapshot<ProcessorOptions> processorOptions, IProfileLoader profileLoader, IProcessorAccessor processorAccessor, IMaintenanceLoader maintenanceLoader, IMigrationInformationLoader migrationLoader, ILogger<MigrationRunner> logger, IStopWatch stopWatch, IMigrationRunnerConventionsAccessor migrationRunnerConventionsAccessor, IAssemblySource assemblySource, MigrationValidator migrationValidator, IServiceProvider serviceProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| IOptions<RunnerOptions> | options | The migration runner options |
| IOptionsSnapshot<ProcessorOptions> | processorOptions | The migration processor options |
| IProfileLoader | profileLoader | The profile loader |
| IProcessorAccessor | processorAccessor | The migration processor accessor |
| IMaintenanceLoader | maintenanceLoader | The maintenance loader |
| IMigrationInformationLoader | migrationLoader | The migration loader |
| ILogger<MigrationRunner> | logger | The logger |
| IStopWatch | stopWatch | The stopwatch |
| IMigrationRunnerConventionsAccessor | migrationRunnerConventionsAccessor | The accessor for migration runner conventions |
| IAssemblySource | assemblySource | The assemblies to scan for migrations, etc... |
| MigrationValidator | migrationValidator | The validator for migrations |
| IServiceProvider | serviceProvider | The service provider |
MigrationRunner(IOptions<RunnerOptions>, IOptionsSnapshot<ProcessorOptions>, IProfileLoader, IProcessorAccessor, IMaintenanceLoader, IMigrationInformationLoader, ILogger<MigrationRunner>, IStopWatch, IMigrationRunnerConventionsAccessor, IAssemblySource, MigrationValidator, IServiceProvider, IMigrationScopeManager)
Initializes a new instance of the MigrationRunner class.
Declaration
public MigrationRunner(IOptions<RunnerOptions> options, IOptionsSnapshot<ProcessorOptions> processorOptions, IProfileLoader profileLoader, IProcessorAccessor processorAccessor, IMaintenanceLoader maintenanceLoader, IMigrationInformationLoader migrationLoader, ILogger<MigrationRunner> logger, IStopWatch stopWatch, IMigrationRunnerConventionsAccessor migrationRunnerConventionsAccessor, IAssemblySource assemblySource, MigrationValidator migrationValidator, IServiceProvider serviceProvider, IMigrationScopeManager migrationScopeHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| IOptions<RunnerOptions> | options | The migration runner options |
| IOptionsSnapshot<ProcessorOptions> | processorOptions | The migration processor options |
| IProfileLoader | profileLoader | The profile loader |
| IProcessorAccessor | processorAccessor | The migration processor accessor |
| IMaintenanceLoader | maintenanceLoader | The maintenance loader |
| IMigrationInformationLoader | migrationLoader | The migration loader |
| ILogger<MigrationRunner> | logger | The logger |
| IStopWatch | stopWatch | The stopwatch |
| IMigrationRunnerConventionsAccessor | migrationRunnerConventionsAccessor | The accessor for migration runner conventions |
| IAssemblySource | assemblySource | The assemblies to scan for migrations, etc... |
| MigrationValidator | migrationValidator | The validator for migrations |
| IServiceProvider | serviceProvider | The service provider |
| IMigrationScopeManager | migrationScopeHandler | THe migration scope handler |
MigrationRunner(Assembly, IRunnerContext, IMigrationProcessor)
Initializes a new instance of the MigrationRunner class.
Declaration
[Obsolete]
public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The assembly to scan for migrations, etc... |
| IRunnerContext | runnerContext | The runner context |
| IMigrationProcessor | processor | The migration processor |
MigrationRunner(Assembly, IRunnerContext, IMigrationProcessor, IConventionSet)
Initializes a new instance of the MigrationRunner class.
Declaration
[Obsolete]
public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor, IConventionSet conventionSet)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The assembly to scan for migrations, etc... |
| IRunnerContext | runnerContext | The runner context |
| IMigrationProcessor | processor | The migration processor |
| IConventionSet | conventionSet | The expression convention set |
Properties
| Edit this page View SourceCaughtExceptions
Gets the caught exceptions when SilentlyFail is true
Declaration
public IReadOnlyList<Exception> CaughtExceptions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<Exception> |
Conventions
Gets the migration runner conventions
Declaration
public IMigrationRunnerConventions Conventions { get; }
Property Value
| Type | Description |
|---|---|
| IMigrationRunnerConventions |
CurrentScope
Gets or sets the currently active migration scope. Setter for IMigrationScopeManager was removed. Setter for this property will throw exception when custom migration scope handler is used
Declaration
public IMigrationScope CurrentScope { get; set; }
Property Value
| Type | Description |
|---|---|
| IMigrationScope |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown when custom IMigrationScopeManager implementation is used |
MaintenanceLoader
Gets the maintenance loader
Declaration
public IMaintenanceLoader MaintenanceLoader { get; }
Property Value
| Type | Description |
|---|---|
| IMaintenanceLoader |
MigrationAssemblies
Gets the assemblies searched for migrations, profile migrations, etc...
Declaration
[Obsolete]
public IAssemblyCollection MigrationAssemblies { get; }
Property Value
| Type | Description |
|---|---|
| IAssemblyCollection |
MigrationLoader
Gets or sets the migration loader to be used by this migration runner
Declaration
public IMigrationInformationLoader MigrationLoader { get; set; }
Property Value
| Type | Description |
|---|---|
| IMigrationInformationLoader |
Processor
Gets the migration processor used by this runner
Declaration
public IMigrationProcessor Processor { get; }
Property Value
| Type | Description |
|---|---|
| IMigrationProcessor |
ProfileLoader
Gets or sets the profile loader
Declaration
public IProfileLoader ProfileLoader { get; set; }
Property Value
| Type | Description |
|---|---|
| IProfileLoader |
RunnerContext
Gets the runner context
Declaration
[Obsolete]
public IRunnerContext RunnerContext { get; }
Property Value
| Type | Description |
|---|---|
| IRunnerContext |
SilentlyFail
Gets a value indicating whether exceptions should be caught
Declaration
public bool SilentlyFail { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
TransactionPerSession
Gets a value indicating whether a single transaction for the whole session should be used
Declaration
public bool TransactionPerSession { get; }
Property Value
| Type | Description |
|---|---|
| bool |
VersionLoader
Gets or sets the version loader
Declaration
public IVersionLoader VersionLoader { get; set; }
Property Value
| Type | Description |
|---|---|
| IVersionLoader |
Methods
| Edit this page View SourceApplyMaintenance(MigrationStage, bool)
Apply maintenance changes
Declaration
public void ApplyMaintenance(MigrationStage stage, bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| MigrationStage | stage | The maintenance stage |
| bool | useAutomaticTransactionManagement |
|
ApplyMigrationDown(IMigrationInfo, bool)
Revert the migration using the given migration information
Declaration
public virtual void ApplyMigrationDown(IMigrationInfo migrationInfo, bool useTransaction)
Parameters
| Type | Name | Description |
|---|---|---|
| IMigrationInfo | migrationInfo | The migration information |
| bool | useTransaction |
|
ApplyMigrationUp(IMigrationInfo, bool)
Apply the migration using the given migration information
Declaration
public virtual void ApplyMigrationUp(IMigrationInfo migrationInfo, bool useTransaction)
Parameters
| Type | Name | Description |
|---|---|---|
| IMigrationInfo | migrationInfo | The migration information |
| bool | useTransaction |
|
ApplyProfiles()
Apply all matching profiles
Declaration
public void ApplyProfiles()
BeginScope()
Starts a new migration scope
Declaration
public IMigrationScope BeginScope()
Returns
| Type | Description |
|---|---|
| IMigrationScope | A new migration scope |
Down(IMigration)
Executes an Down migration
Declaration
public void Down(IMigration migration)
Parameters
| Type | Name | Description |
|---|---|---|
| IMigration | migration | The migration to execute |
ExecuteExpressions(ICollection<IMigrationExpression>)
Execute each migration expression in the expression collection
Declaration
protected void ExecuteExpressions(ICollection<IMigrationExpression> expressions)
Parameters
| Type | Name | Description |
|---|---|---|
| ICollection<IMigrationExpression> | expressions | The expressions to execute |
HasMigrationsToApplyDown(long)
Returns true when there are migrations to revert
Declaration
public bool HasMigrationsToApplyDown(long version)
Parameters
| Type | Name | Description |
|---|---|---|
| long | version | The target version |
Returns
| Type | Description |
|---|---|
| bool |
|
HasMigrationsToApplyRollback()
Are there migrations available for a rollback?
Declaration
public bool HasMigrationsToApplyRollback()
Returns
| Type | Description |
|---|---|
| bool |
|
HasMigrationsToApplyUp(long?)
Returns true when there are migrations to apply
Declaration
public bool HasMigrationsToApplyUp(long? version = null)
Parameters
| Type | Name | Description |
|---|---|---|
| long? | version | The target version (or |
Returns
| Type | Description |
|---|---|
| bool |
|
ListMigrations()
List all migrations to the logger
Declaration
public void ListMigrations()
MigrateDown(long)
Migrate down to the given version
Declaration
public void MigrateDown(long targetVersion)
Parameters
| Type | Name | Description |
|---|---|---|
| long | targetVersion |
MigrateDown(long, bool)
Revert migrations down to the given targetVersion
Declaration
public void MigrateDown(long targetVersion, bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| long | targetVersion | The target version that should become the last applied migration version |
| bool | useAutomaticTransactionManagement |
|
MigrateUp()
Executes all found (and unapplied) migrations
Declaration
public void MigrateUp()
MigrateUp(bool)
Apply migrations
Declaration
public void MigrateUp(bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | useAutomaticTransactionManagement |
|
MigrateUp(long)
Executes all found (and unapplied) migrations up to the given version
Declaration
public void MigrateUp(long targetVersion)
Parameters
| Type | Name | Description |
|---|---|---|
| long | targetVersion |
MigrateUp(long, bool)
Apply migrations up to the given targetVersion
Declaration
public void MigrateUp(long targetVersion, bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| long | targetVersion | The target migration version |
| bool | useAutomaticTransactionManagement |
|
Rollback(int)
Rollback the given number of steps
Declaration
public void Rollback(int steps)
Parameters
| Type | Name | Description |
|---|---|---|
| int | steps | The number of steps to rollback |
Rollback(int, bool)
Rollback the last steps
Declaration
public void Rollback(int steps, bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| int | steps | The number of migrations to rollback |
| bool | useAutomaticTransactionManagement |
|
RollbackToVersion(long)
Rollback to a given version
Declaration
public void RollbackToVersion(long version)
Parameters
| Type | Name | Description |
|---|---|---|
| long | version | The target version to rollback to |
RollbackToVersion(long, bool)
Rollback to a given version
Declaration
public void RollbackToVersion(long version, bool useAutomaticTransactionManagement)
Parameters
| Type | Name | Description |
|---|---|---|
| long | version | The version to rollback to (exclusive) |
| bool | useAutomaticTransactionManagement |
|
Up(IMigration)
Executes an Up migration
Declaration
public void Up(IMigration migration)
Parameters
| Type | Name | Description |
|---|---|---|
| IMigration | migration | The migration to execute |
ValidateVersionOrder()
Validate that there were no missing migration versions
Declaration
public void ValidateVersionOrder()
Remarks
Throws an exception if a missing migration was found.