Skip to content

Commit

Permalink
Fixing SQL exception during automatic migrations in PostgreSql
Browse files Browse the repository at this point in the history
Fixes #6783
Fixes #7323
  • Loading branch information
sebastienros committed Oct 17, 2016
1 parent bd22290 commit 59a9f0b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Orchard/Data/Migration/AutomaticDataMigrations.cs
Expand Up @@ -80,12 +80,25 @@ public class AutomaticDataMigrations : IOrchardShellEvents {
/// <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();
}
}
}
}

0 comments on commit 59a9f0b

Please sign in to comment.