Fixing PostgreSQL when creating DistributedLocks table

This commit is contained in:
hopla 2016-04-12 20:52:06 +02:00 committed by Sébastien Ros
parent a4f2e040b2
commit 010b1884bd
2 changed files with 4 additions and 9 deletions
src/Orchard

View File

@ -84,8 +84,11 @@ namespace Orchard.Data.Migration {
// Ensure the distributed lock record schema exists.
var schemaBuilder = new SchemaBuilder(_dataMigrationInterpreter);
var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder);
if (distributedLockSchemaBuilder.EnsureSchema())
if (!distributedLockSchemaBuilder.SchemaExists()) {
// Workaround to avoid some Transaction issue for PostgreSQL.
_transactionManager.RequireNew();
distributedLockSchemaBuilder.CreateSchema();
}
}
}
}

View File

@ -13,14 +13,6 @@ namespace Orchard.Tasks.Locking.Services {
_schemaBuilder = schemaBuilder;
}
public bool EnsureSchema() {
if (SchemaExists())
return false;
CreateSchema();
return true;
}
public void CreateSchema() {
_schemaBuilder.CreateTable(TableName, table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())