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:
Sipke Schoorstra
2015-09-08 20:56:28 +01:00
parent 94db186b37
commit e9f883c296
4 changed files with 9 additions and 9 deletions

View File

@@ -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");

View File

@@ -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();
}
}
}

View File

@@ -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() {

View File

@@ -110,7 +110,7 @@ namespace Orchard.Tasks.Locking.Services {
);
});
return result;
return result;
}
private DistributedLock AcquireLockInternal(string name, TimeSpan? maxValidFor) {