Further simplify upgrader
This commit is contained in:
@@ -15,8 +15,12 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
{
|
||||
private PostMigrationCollection _postMigrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override MigrationPlan CreatePlan() => new UmbracoPlan();
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see ref="UmbracoUpgrader" /> class.
|
||||
/// </summary>
|
||||
public UmbracoUpgrader()
|
||||
: base(new UmbracoPlan())
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Executes.
|
||||
|
||||
@@ -6,11 +6,17 @@ using Umbraco.Core.Services;
|
||||
namespace Umbraco.Core.Migrations.Upgrade
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an abstract base class for creating upgraders.
|
||||
/// Represents an upgrader.
|
||||
/// </summary>
|
||||
public abstract class Upgrader
|
||||
public class Upgrader
|
||||
{
|
||||
private MigrationPlan _plan;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see ref="Upgrader"/> class.
|
||||
/// </summary>
|
||||
public Upgrader(MigrationPlan plan)
|
||||
{
|
||||
Plan = plan;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the migration plan.
|
||||
@@ -20,12 +26,7 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
/// <summary>
|
||||
/// Gets the migration plan.
|
||||
/// </summary>
|
||||
public MigrationPlan Plan => _plan ?? (_plan = CreatePlan());
|
||||
|
||||
/// <summary>
|
||||
/// Creates the migration plan.
|
||||
/// </summary>
|
||||
protected abstract MigrationPlan CreatePlan();
|
||||
public MigrationPlan Plan { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key for the state value.
|
||||
|
||||
@@ -5,6 +5,7 @@ using NUnit.Framework;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations;
|
||||
using Umbraco.Core.Migrations.Install;
|
||||
using Umbraco.Core.Migrations.Upgrade;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -34,7 +35,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var upgrader = new MigrationTests.TestUpgrader(
|
||||
var upgrader = new Upgrader(
|
||||
new MigrationPlan("test")
|
||||
.From(string.Empty)
|
||||
.To<CreateTableOfTDtoMigration>("done"));
|
||||
@@ -72,7 +73,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var upgrader = new MigrationTests.TestUpgrader(
|
||||
var upgrader = new Upgrader(
|
||||
new MigrationPlan("test")
|
||||
.From(string.Empty)
|
||||
.To<CreateTableOfTDtoMigration>("a")
|
||||
@@ -108,7 +109,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var upgrader = new MigrationTests.TestUpgrader(
|
||||
var upgrader = new Upgrader(
|
||||
new MigrationPlan("test")
|
||||
.From(string.Empty)
|
||||
.To<CreateTableOfTDtoMigration>("a")
|
||||
@@ -145,7 +146,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var upgrader = new MigrationTests.TestUpgrader(
|
||||
var upgrader = new Upgrader(
|
||||
new MigrationPlan("test")
|
||||
.From(string.Empty)
|
||||
.To<CreateTableOfTDtoMigration>("a")
|
||||
@@ -180,7 +181,7 @@ namespace Umbraco.Tests.Migrations
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var upgrader = new MigrationTests.TestUpgrader(
|
||||
var upgrader = new Upgrader(
|
||||
new MigrationPlan("test")
|
||||
.From(string.Empty)
|
||||
.To<CreateTableOfTDtoMigration>("a")
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Semver;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Migrations;
|
||||
using Umbraco.Core.Migrations.Upgrade;
|
||||
@@ -18,22 +16,7 @@ namespace Umbraco.Tests.Migrations
|
||||
[TestFixture]
|
||||
public class MigrationTests
|
||||
{
|
||||
public class TestUpgrader : Upgrader
|
||||
{
|
||||
private readonly MigrationPlan _plan;
|
||||
|
||||
public TestUpgrader(MigrationPlan plan)
|
||||
{
|
||||
_plan = plan;
|
||||
}
|
||||
|
||||
protected override MigrationPlan CreatePlan()
|
||||
{
|
||||
return _plan;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestUpgraderWithPostMigrations : TestUpgrader
|
||||
public class TestUpgraderWithPostMigrations : Upgrader
|
||||
{
|
||||
private PostMigrationCollection _postMigrations;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user