post merge fixes
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Composing;
|
||||
using Umbraco.Cms.Core.Migrations;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Packaging
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Base class for package migration plans
|
||||
/// </summary>
|
||||
public abstract class PackageMigrationPlan : MigrationPlan, IDiscoverable
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a package migration plan
|
||||
/// </summary>
|
||||
/// <param name="packageName">The name of the package. If the package has a package.manifest these must match.</param>
|
||||
protected PackageMigrationPlan(string packageName) : this(packageName, packageName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a plan for a Package Name
|
||||
/// </summary>
|
||||
/// <param name="packageName">The package name that the plan is for. If the package has a package.manifest these must match.</param>
|
||||
/// <param name="planName">
|
||||
/// The plan name for the package. This should be the same name as the
|
||||
/// package name if there is only one plan in the package.
|
||||
/// </param>
|
||||
protected PackageMigrationPlan(string packageName, string planName) : base(planName)
|
||||
{
|
||||
// A call to From must be done first
|
||||
From(string.Empty);
|
||||
|
||||
DefinePlan();
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inform the plan executor to ignore all saved package state and
|
||||
/// run the migration from initial state to it's end state.
|
||||
/// </summary>
|
||||
public override bool IgnoreCurrentState => true;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Package Name for this plan
|
||||
/// </summary>
|
||||
public string PackageName { get; }
|
||||
|
||||
protected abstract void DefinePlan();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Cms.Core.Composing;
|
||||
|
||||
namespace Umbraco.Cms.Core.Packaging
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of <see cref="PackageMigrationPlan"/>
|
||||
/// </summary>
|
||||
public class PackageMigrationPlanCollection : BuilderCollectionBase<PackageMigrationPlan>
|
||||
{
|
||||
public PackageMigrationPlanCollection(IEnumerable<PackageMigrationPlan> items) : base(items)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Umbraco.Cms.Core.Composing;
|
||||
|
||||
namespace Umbraco.Cms.Core.Packaging
|
||||
{
|
||||
public class PackageMigrationPlanCollectionBuilder : LazyCollectionBuilderBase<PackageMigrationPlanCollectionBuilder, PackageMigrationPlanCollection, PackageMigrationPlan>
|
||||
{
|
||||
protected override PackageMigrationPlanCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Packaging
|
||||
{
|
||||
public class PendingPackageMigrations
|
||||
{
|
||||
private readonly ILogger<PendingPackageMigrations> _logger;
|
||||
private readonly PackageMigrationPlanCollection _packageMigrationPlans;
|
||||
|
||||
public PendingPackageMigrations(
|
||||
ILogger<PendingPackageMigrations> logger,
|
||||
PackageMigrationPlanCollection packageMigrationPlans)
|
||||
{
|
||||
_logger = logger;
|
||||
_packageMigrationPlans = packageMigrationPlans;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns what package migration names are pending
|
||||
/// </summary>
|
||||
/// <param name="keyValues">
|
||||
/// These are the key/value pairs from the keyvalue storage of migration names and their final values
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public IReadOnlyList<string> GetPendingPackageMigrations(IReadOnlyDictionary<string, string> keyValues)
|
||||
{
|
||||
var packageMigrationPlans = _packageMigrationPlans.ToList();
|
||||
|
||||
var pendingMigrations = new List<string>(packageMigrationPlans.Count);
|
||||
|
||||
foreach (PackageMigrationPlan plan in packageMigrationPlans)
|
||||
{
|
||||
string currentMigrationState = null;
|
||||
var planKeyValueKey = Constants.Conventions.Migrations.KeyValuePrefix + plan.Name;
|
||||
if (keyValues.TryGetValue(planKeyValueKey, out var value))
|
||||
{
|
||||
currentMigrationState = value;
|
||||
|
||||
if (!plan.FinalState.InvariantEquals(value))
|
||||
{
|
||||
// Not equal so we need to run
|
||||
pendingMigrations.Add(plan.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If there is nothing in the DB then we need to run
|
||||
pendingMigrations.Add(plan.Name);
|
||||
}
|
||||
|
||||
_logger.LogDebug("Final package migration for {PackagePlan} state is {FinalMigrationState}, database contains {DatabaseState}",
|
||||
plan.Name,
|
||||
plan.FinalState,
|
||||
currentMigrationState ?? "<null>");
|
||||
}
|
||||
|
||||
return pendingMigrations;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user