Class MigrationPlan
Represents a migration plan.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Migrations
Assembly: Umbraco.Infrastructure.dll
Syntax
public class MigrationPlan
Constructors
View SourceMigrationPlan(string)
Initializes a new instance of the MigrationPlan class.
Declaration
public MigrationPlan(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the plan. |
Properties
View SourceFinalState
Gets the final state.
Declaration
public string FinalState { get; }
Property Value
| Type | Description |
|---|---|
| string |
IgnoreCurrentState
If set to true the plan executor will ignore any current state persisted and run the plan from its initial state to its end state.
Declaration
public virtual bool IgnoreCurrentState { get; }
Property Value
| Type | Description |
|---|---|
| bool |
InitialState
Gets the initial state.
Declaration
public virtual string InitialState { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
The initial state is the state when the plan has never run. By default, it is the empty string, but plans may override it if they have other ways of determining where to start from.
Name
Gets the name of the plan.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Transitions
Gets the transitions.
Declaration
public IReadOnlyDictionary<string, MigrationPlan.Transition?> Transitions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, MigrationPlan.Transition> |
Methods
View SourceCreateRandomState()
Creates a random, unique state as a string in GUID format.
Declaration
public virtual string CreateRandomState()
Returns
| Type | Description |
|---|---|
| string | A string containing a randomly generated, unique GUID in braces and uppercase. |
From(string?)
Specifies the starting state for the migration plan, which determines where migrations begin execution.
Declaration
public MigrationPlan From(string? sourceState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceState | The starting state to set for the migration plan. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The current MigrationPlan instance, allowing for method chaining. |
Merge()
Initiates the process of merging multiple migration branches into a single branch within the migration plan.
Declaration
public MergeBuilder Merge()
Returns
| Type | Description |
|---|---|
| MergeBuilder | A Umbraco.Cms.Infrastructure.Migrations.MigrationPlan.MergeBuilder instance used to configure and define the merge operation. |
ThrowOnUnknownInitialState(string)
Throws an exception when the specified initial state is unknown to the migration plan.
Declaration
public virtual void ThrowOnUnknownInitialState(string state)
Parameters
| Type | Name | Description |
|---|---|---|
| string | state | The initial state value that is not recognized by the migration plan. |
To(Guid)
Adds a transition to the specified target state through an empty migration.
Declaration
public MigrationPlan To(Guid targetState)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | targetState | The target state to transition to. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The updated MigrationPlan instance. |
To(Guid, Type)
Adds a transition to a target state through the specified migration type.
Declaration
public MigrationPlan To(Guid targetState, Type migration)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | targetState | The target state to transition to. |
| Type | migration | The type of migration to apply for the transition. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The updated MigrationPlan instance. |
To(string)
Adds a transition to the specified target state using an empty (no-operation) migration.
Declaration
public MigrationPlan To(string targetState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | targetState | The target state to transition to. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The updated MigrationPlan instance. |
To(string, Type?)
Adds a transition to a target state through a migration.
Declaration
public MigrationPlan To(string targetState, Type? migration)
Parameters
| Type | Name | Description |
|---|---|---|
| string | targetState | The target state to transition to. |
| Type | migration | The type of migration to apply during the transition. This should be a System.Type derived from |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The updated MigrationPlan instance. |
ToWithClone(string, string, string)
Adds transitions to a targetState by cloning the transition chain from startState up to (but not including) endState.
Declaration
public MigrationPlan ToWithClone(string startState, string endState, string targetState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | startState | The initial state from which the transition chain will be cloned. |
| string | endState | The state at which to stop cloning transitions (exclusive). |
| string | targetState | The state to which the final cloned transition will point instead of |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The current MigrationPlan instance with the added transitions. |
ToWithReplace<TMigrationNew>(string, string)
Adds a transition to a new target state using the specified migration, replacing a previous migration for the given state.
Declaration
public MigrationPlan ToWithReplace<TMigrationNew>(string recoverState, string targetState) where TMigrationNew : AsyncMigrationBase
Parameters
| Type | Name | Description |
|---|---|---|
| string | recoverState | The previous target state that can be recovered from directly. |
| string | targetState | The new target state to transition to. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The MigrationPlan instance with the updated transition. |
Type Parameters
| Name | Description |
|---|---|
| TMigrationNew | The migration to apply to reach the new target state. |
ToWithReplace<TMigrationNew, TMigrationRecover>(string, string)
Adds a transition to a new target state through a migration, replacing a previous migration with a recovery migration for the old state.
Declaration
public MigrationPlan ToWithReplace<TMigrationNew, TMigrationRecover>(string recoverState, string targetState) where TMigrationNew : AsyncMigrationBase where TMigrationRecover : AsyncMigrationBase
Parameters
| Type | Name | Description |
|---|---|---|
| string | recoverState | The previous target state that should be recovered from using
|
| string | targetState | The new target state to transition to. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The current MigrationPlan instance, allowing for method chaining. |
Type Parameters
| Name | Description |
|---|---|
| TMigrationNew | The migration to apply for the new target state. |
| TMigrationRecover | The migration to use to recover from the previous target state. |
To<TMigration>(Guid)
Declaration
public MigrationPlan To<TMigration>(Guid targetState) where TMigration : AsyncMigrationBase
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | targetState |
Returns
| Type | Description |
|---|---|
| MigrationPlan |
Type Parameters
| Name | Description |
|---|---|
| TMigration |
To<TMigration>(string)
Adds a transition from the current state to the specified target state using the specified migration type.
Declaration
public MigrationPlan To<TMigration>(string targetState) where TMigration : AsyncMigrationBase
Parameters
| Type | Name | Description |
|---|---|---|
| string | targetState | The name of the target state to transition to. |
Returns
| Type | Description |
|---|---|
| MigrationPlan | The current MigrationPlan instance, allowing for method chaining. |
Type Parameters
| Name | Description |
|---|---|
| TMigration | The type of IMigration to execute for the transition. |
Validate()
Validates the plan.
Declaration
public void Validate()