Fixing SQL exception during automatic migrations in PostgreSql

Fixes #6783
Fixes #7323
This commit is contained in:
Sebastien Ros 2016-10-17 14:34:37 -07:00
parent bd222908d6
commit 59a9f0bf03

View File

@ -80,12 +80,25 @@ namespace Orchard.Data.Migration {
/// <summary>
/// This ensures that the framework migrations have run for the distributed locking feature, as existing Orchard installations will not have the required tables when upgrading.
/// </summary>
private void EnsureDistributedLockSchemaExists() {
private void EnsureDistributedLockSchemaExists()
{
// 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.
if (_shellSettings.DataProvider.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase))
{
_transactionManager.RequireNew();
distributedLockSchemaBuilder.CreateSchema();
return;
}
distributedLockSchemaBuilder.CreateSchema();
_transactionManager.RequireNew();
}
}
}
}