Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@
To<V_17_4_0.AddExternalMemberTables>("{D7E8F9A0-B1C2-4D3E-A5F6-7890ABCDEF12}");
To<V_17_4_0.FixLabelDataTypeDbTypeFromConfiguration>("{3F9B6A1C-7D84-4E2B-9C15-6A2E8F3D5B47}");

// To 17.6.0
To<V_17_6_0.AddContentTypeIdIndexForContent>("{3A1A8047-74AE-491A-B2C4-0BAE4A1289EC}");

Check warning on line 191 in src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (v17/dev)

❌ Getting worse: Large Method

DefinePlan increases from 79 to 80 lines of code, threshold = 70 Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
// To 18.0.0
// TODO (V18): Enable on 18 branch
//// To<V_18_0_0.MigrateSingleBlockList>("{74332C49-B279-4945-8943-F8F00B1F5949}");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.

using Umbraco.Cms.Infrastructure.Persistence.Dtos;

namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_17_6_0;

/// <summary>
/// Adds an index on the contentTypeId column of the umbracoContent table to support efficient
/// content-type-scoped queries (e.g. the content cache rebuild triggered by content type changes).
/// </summary>
public class AddContentTypeIdIndexForContent : AsyncMigrationBase
{
private const string IndexName = "IX_" + ContentDto.TableName + "_" + ContentDto.ContentTypeIdColumnName;

/// <summary>
/// Initializes a new instance of the <see cref="AddContentTypeIdIndexForContent"/> class.
/// </summary>
/// <param name="context">The migration context.</param>
public AddContentTypeIdIndexForContent(IMigrationContext context)
: base(context)
{
}

/// <inheritdoc/>
protected override Task MigrateAsync()
{
if (IndexExists(IndexName))
{
return Task.CompletedTask;
}

// Give scope for the migration to complete within the command timeout, which may be necessary on large datasets.
EnsureLongCommandTimeout(Database);

// Create the index from the definition on ContentDto, so it matches a fresh install exactly.
CreateIndex<ContentDto>(IndexName);

return Task.CompletedTask;
}
}
1 change: 1 addition & 0 deletions src/Umbraco.Infrastructure/Persistence/Dtos/ContentDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ContentDto
/// </summary>
[Column(ContentTypeIdColumnName)]
[ForeignKey(typeof(ContentTypeDto), Column = ContentTypeDto.NodeIdColumnName)]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_" + ContentTypeIdColumnName)]
public int ContentTypeId { get; set; }

/// <summary>
Expand Down
Loading