mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Easing migration from old Orchard versions by checking for mandatory core modules.
--HG-- branch : 1.x
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using Orchard.Environment;
|
using Orchard.Environment;
|
||||||
|
using Orchard.Environment.Features;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
|
||||||
namespace Orchard.Data.Migration {
|
namespace Orchard.Data.Migration {
|
||||||
@@ -11,9 +10,14 @@ namespace Orchard.Data.Migration {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AutomaticDataMigrations : IOrchardShellEvents {
|
public class AutomaticDataMigrations : IOrchardShellEvents {
|
||||||
private readonly IDataMigrationManager _dataMigrationManager;
|
private readonly IDataMigrationManager _dataMigrationManager;
|
||||||
|
private readonly IFeatureManager _featureManager;
|
||||||
|
|
||||||
public AutomaticDataMigrations(IDataMigrationManager dataMigrationManager) {
|
public AutomaticDataMigrations(
|
||||||
|
IDataMigrationManager dataMigrationManager,
|
||||||
|
IFeatureManager featureManager
|
||||||
|
) {
|
||||||
_dataMigrationManager = dataMigrationManager;
|
_dataMigrationManager = dataMigrationManager;
|
||||||
|
_featureManager = featureManager;
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
@@ -21,6 +25,18 @@ namespace Orchard.Data.Migration {
|
|||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public void Activated() {
|
public void Activated() {
|
||||||
|
|
||||||
|
// Let's make sure that the basic set of features is enabled. If there are any that are not enabled, then let's enable them first.
|
||||||
|
var theseFeaturesShouldAlwaysBeActive = new[] {
|
||||||
|
"Common", "Containers", "Contents", "Dashboard", "Feeds", "Navigation", "Reports", "Scheduling", "Settings", "Shapes", "Title"
|
||||||
|
};
|
||||||
|
|
||||||
|
var enabledFeatures = _featureManager.GetEnabledFeatures().Select(f => f.Id).ToList();
|
||||||
|
var featuresToEnable = theseFeaturesShouldAlwaysBeActive.Where(shouldBeActive => !enabledFeatures.Contains(shouldBeActive)).ToList();
|
||||||
|
if (featuresToEnable.Any()) {
|
||||||
|
_featureManager.EnableFeatures(featuresToEnable);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var feature in _dataMigrationManager.GetFeaturesThatNeedUpdate()) {
|
foreach (var feature in _dataMigrationManager.GetFeaturesThatNeedUpdate()) {
|
||||||
try {
|
try {
|
||||||
_dataMigrationManager.Update(feature);
|
_dataMigrationManager.Update(feature);
|
||||||
|
Reference in New Issue
Block a user