Fixes: U4-7120 SQL Fail upgrading om 7.2.4 to 7.3 - due to index on master col
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
|
||||
@@ -118,6 +119,22 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZe
|
||||
}
|
||||
|
||||
|
||||
var dbIndexes = SqlSyntax.GetDefinedIndexes(Context.Database)
|
||||
.Select(x => new DbIndexDefinition()
|
||||
{
|
||||
TableName = x.Item1,
|
||||
IndexName = x.Item2,
|
||||
ColumnName = x.Item3,
|
||||
IsUnique = x.Item4
|
||||
}).ToArray();
|
||||
|
||||
//in some databases there's an index (IX_Master) on the master column which needs to be dropped first
|
||||
var foundIndex = dbIndexes.FirstOrDefault(x => x.TableName.InvariantEquals("cmsTemplate") && x.ColumnName.InvariantEquals("master"));
|
||||
if (foundIndex != null)
|
||||
{
|
||||
Delete.Index(foundIndex.IndexName).OnTable("cmsTemplate");
|
||||
}
|
||||
|
||||
if (cols.Any(x => x.ColumnName.InvariantEquals("master") && x.TableName.InvariantEquals("cmsTemplate")))
|
||||
{
|
||||
Delete.Column("master").FromTable("cmsTemplate");
|
||||
|
||||
Reference in New Issue
Block a user