mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Removed unnecessary call to DistributedLockSchemaBuilder.
Also added code to commit the transaction if the schema was created so that it can be used in the same request (DataMigrationManager is doing the same after each migration).
This commit is contained in:
@@ -23,7 +23,6 @@ using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tasks.Locking.Services;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Setup.Services {
|
||||
@@ -155,10 +154,6 @@ namespace Orchard.Setup.Services {
|
||||
schemaBuilder.AlterTable("Orchard_Framework_DataMigrationRecord",
|
||||
table => table.AddUniqueConstraint("UC_DMR_DataMigrationClass_Version", "DataMigrationClass", "Version"));
|
||||
|
||||
// Create the distributed lock record schema.
|
||||
var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder);
|
||||
distributedLockSchemaBuilder.CreateSchema();
|
||||
|
||||
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
||||
dataMigrationManager.Update("Settings");
|
||||
|
||||
|
||||
@@ -18,18 +18,21 @@ namespace Orchard.Data.Migration {
|
||||
private readonly IDistributedLockService _distributedLockService;
|
||||
private readonly IDataMigrationInterpreter _dataMigrationInterpreter;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
|
||||
public AutomaticDataMigrations(
|
||||
IDataMigrationManager dataMigrationManager,
|
||||
IDataMigrationInterpreter dataMigrationInterpreter,
|
||||
IFeatureManager featureManager,
|
||||
IDistributedLockService distributedLockService,
|
||||
ITransactionManager transactionManager,
|
||||
ShellSettings shellSettings) {
|
||||
|
||||
_dataMigrationManager = dataMigrationManager;
|
||||
_featureManager = featureManager;
|
||||
_distributedLockService = distributedLockService;
|
||||
_shellSettings = shellSettings;
|
||||
_transactionManager = transactionManager;
|
||||
_dataMigrationInterpreter = dataMigrationInterpreter;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
@@ -77,7 +80,8 @@ namespace Orchard.Data.Migration {
|
||||
// Ensure the distributed lock record schema exists.
|
||||
var schemaBuilder = new SchemaBuilder(_dataMigrationInterpreter);
|
||||
var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder);
|
||||
distributedLockSchemaBuilder.EnsureSchema();
|
||||
if (distributedLockSchemaBuilder.EnsureSchema())
|
||||
_transactionManager.RequireNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ namespace Orchard.Tasks.Locking.Services {
|
||||
_schemaBuilder = schemaBuilder;
|
||||
}
|
||||
|
||||
public void EnsureSchema() {
|
||||
public bool EnsureSchema() {
|
||||
if (SchemaExists())
|
||||
return;
|
||||
return false;
|
||||
|
||||
CreateSchema();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CreateSchema() {
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Orchard.Tasks.Locking.Services {
|
||||
);
|
||||
});
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
private DistributedLock AcquireLockInternal(string name, TimeSpan? maxValidFor) {
|
||||
|
||||
Reference in New Issue
Block a user