Merge pull request #7562 from stevemegson/v8/migrations/propertydata-index

Migrations - Create temporary index on umbracoPropertyData
This commit is contained in:
Shannon Deminick
2020-02-04 15:35:01 +11:00
committed by GitHub
2 changed files with 11 additions and 0 deletions
@@ -12,6 +12,7 @@ namespace Umbraco.Core.Migrations.Upgrade.Common
{
// remove those that may already have keys
Delete.KeysAndIndexes(Constants.DatabaseSchema.Tables.KeyValue).Do();
Delete.KeysAndIndexes(Constants.DatabaseSchema.Tables.PropertyData).Do();
// re-create *all* keys and indexes
foreach (var x in DatabaseSchemaCreator.OrderedTables)
@@ -19,6 +19,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
public override void Migrate()
{
MigratePropertyData();
CreatePropertyDataIndexes();
MigrateContentAndPropertyTypes();
MigrateContent();
MigrateVersions();
@@ -90,6 +91,15 @@ HAVING COUNT(v2.id) <> 1").Any())
Rename.Table(PreTables.PropertyData).To(Constants.DatabaseSchema.Tables.PropertyData).Do();
}
private void CreatePropertyDataIndexes()
{
// Creates a temporary index on umbracoPropertyData to speed up other migrations which update property values.
// It will be removed in CreateKeysAndIndexes before the normal indexes for the table are created
var tableDefinition = Persistence.DatabaseModelDefinitions.DefinitionFactory.GetTableDefinition(typeof(PropertyDataDto), SqlSyntax);
Execute.Sql(SqlSyntax.FormatPrimaryKey(tableDefinition)).Do();
Execute.Sql($"CREATE UNIQUE NONCLUSTERED INDEX IX_umbracoPropertyData_Temp ON {PreTables.PropertyData} (versionId,propertyTypeId,languageId,segment)").Do();
}
private void MigrateContentAndPropertyTypes()
{
if (!ColumnExists(PreTables.ContentType, "variations"))