Class MigrationPlanExecutor
Executes migration plans that update the database schema and data as part of the Umbraco migration framework.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Migrations
Assembly: Umbraco.Infrastructure.dll
Syntax
public class MigrationPlanExecutor : IMigrationPlanExecutor
Constructors
View SourceMigrationPlanExecutor(ICoreScopeProvider, IScopeAccessor, ILoggerFactory, IMigrationBuilder, IUmbracoDatabaseFactory, IDatabaseCacheRebuilder, DistributedCache, IKeyValueService, IServiceScopeFactory, AppCaches)
Initializes a new instance of the MigrationPlanExecutor class, responsible for executing migration plans within the Umbraco CMS infrastructure.
Declaration
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 19.")]
public MigrationPlanExecutor(ICoreScopeProvider scopeProvider, IScopeAccessor scopeAccessor, ILoggerFactory loggerFactory, IMigrationBuilder migrationBuilder, IUmbracoDatabaseFactory databaseFactory, IDatabaseCacheRebuilder databaseCacheRebuilder, DistributedCache distributedCache, IKeyValueService keyValueService, IServiceScopeFactory serviceScopeFactory, AppCaches appCaches)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | scopeProvider | Provides access to the core scope for database operations. |
| IScopeAccessor | scopeAccessor | Accesses the current scope context. |
| ILoggerFactory | loggerFactory | Factory for creating logger instances used for logging migration activities. |
| IMigrationBuilder | migrationBuilder | Builds and manages migration steps and plans. |
| IUmbracoDatabaseFactory | databaseFactory | Factory for creating Umbraco database connections. |
| IDatabaseCacheRebuilder | databaseCacheRebuilder | Handles rebuilding of database-level caches after migrations. |
| DistributedCache | distributedCache | Manages distributed cache invalidation and synchronization. |
| IKeyValueService | keyValueService | Service for storing and retrieving key-value pairs, often used for migration state. |
| IServiceScopeFactory | serviceScopeFactory | Factory for creating service scopes, enabling dependency injection within migration execution. |
| AppCaches | appCaches | Provides access to application-level caches. |
MigrationPlanExecutor(ICoreScopeProvider, IScopeAccessor, ILoggerFactory, IMigrationBuilder, IUmbracoDatabaseFactory, IDatabaseCacheRebuilder, DistributedCache, IKeyValueService, IServiceScopeFactory, AppCaches, IPublishedContentTypeFactory)
Initializes a new instance of the MigrationPlanExecutor class, responsible for executing migration plans within the Umbraco CMS infrastructure.
Declaration
public MigrationPlanExecutor(ICoreScopeProvider scopeProvider, IScopeAccessor scopeAccessor, ILoggerFactory loggerFactory, IMigrationBuilder migrationBuilder, IUmbracoDatabaseFactory databaseFactory, IDatabaseCacheRebuilder databaseCacheRebuilder, DistributedCache distributedCache, IKeyValueService keyValueService, IServiceScopeFactory serviceScopeFactory, AppCaches appCaches, IPublishedContentTypeFactory publishedContentTypeFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | scopeProvider | Provides access to core database transaction scopes. |
| IScopeAccessor | scopeAccessor | Accesses the current database scope for migration operations. |
| ILoggerFactory | loggerFactory | Factory for creating loggers used during migration execution. |
| IMigrationBuilder | migrationBuilder | Builds and manages migration steps and plans. |
| IUmbracoDatabaseFactory | databaseFactory | Factory for creating Umbraco database connections. |
| IDatabaseCacheRebuilder | databaseCacheRebuilder | Handles rebuilding of database-level caches after migrations. |
| DistributedCache | distributedCache | Manages distributed cache invalidation related to migration changes. |
| IKeyValueService | keyValueService | Service for storing and retrieving key-value pairs, often used for migration state. |
| IServiceScopeFactory | serviceScopeFactory | Factory for creating service scopes for dependency injection during migrations. |
| AppCaches | appCaches | Provides access to application-level caches. |
| IPublishedContentTypeFactory | publishedContentTypeFactory | Factory for creating published content types, used when migrations affect content models. |
Methods
View SourceExecutePlan(MigrationPlan, string)
Executes the migration plan.
Declaration
[Obsolete("Use ExecutePlanAsync instead. Scheduled for removal in Umbraco 18.")]
public ExecutedMigrationPlan ExecutePlan(MigrationPlan plan, string fromState)
Parameters
| Type | Name | Description |
|---|---|---|
| MigrationPlan | plan | The migration plan to execute. |
| string | fromState | The state to start execution at. |
Returns
| Type | Description |
|---|---|
| ExecutedMigrationPlan | ExecutedMigrationPlan containing information about the plan execution, such as completion state and the steps that ran. |
Remarks
Each migration in the plan, may or may not run in a scope depending on the type of plan.
A plan can complete partially, the changes of each completed migration will be saved.
ExecutePlanAsync(MigrationPlan, string)
Executes the migration plan asynchronously.
Declaration
public Task<ExecutedMigrationPlan> ExecutePlanAsync(MigrationPlan plan, string fromState)
Parameters
| Type | Name | Description |
|---|---|---|
| MigrationPlan | plan | The migration plan to execute. |
| string | fromState | The state to start execution at. |
Returns
| Type | Description |
|---|---|
| Task<ExecutedMigrationPlan> | A Task of ExecutedMigrationPlan containing information about the plan execution, such as completion state and the steps that ran. |
Remarks
Each migration in the plan, may or may not run in a scope depending on the type of plan.
A plan can complete partially, the changes of each completed migration will be saved.