Adds a couple missing indexes

This commit is contained in:
Shannon
2019-12-11 14:29:50 +01:00
parent 29ff95323c
commit fba537928a
5 changed files with 35 additions and 1 deletions

View File

@@ -185,6 +185,7 @@ namespace Umbraco.Core.Migrations.Upgrade
// to 8.6.0
To<AddPropertyTypeValidationMessageColumns>("{3D67D2C8-5E65-47D0-A9E1-DC2EE0779D6B}");
To<MissingContentVersionsIndexes>("{EE288A91-531B-4995-8179-1D62D9AA3E2E}");
//FINAL
}

View File

@@ -3,6 +3,7 @@ using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_6_0
{
public class AddPropertyTypeValidationMessageColumns : MigrationBase
{
public AddPropertyTypeValidationMessageColumns(IMigrationContext context)

View File

@@ -0,0 +1,30 @@
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_6_0
{
public class MissingContentVersionsIndexes : MigrationBase
{
public MissingContentVersionsIndexes(IMigrationContext context) : base(context)
{
}
public override void Migrate()
{
Create
.Index("IX_" + ContentVersionDto.TableName + "_NodeId")
.OnTable(ContentVersionDto.TableName)
.OnColumn("nodeId")
.Ascending()
.WithOptions().NonClustered()
.Do();
Create
.Index("IX_" + ContentVersionDto.TableName + "_Current")
.OnTable(ContentVersionDto.TableName)
.OnColumn("current")
.Ascending()
.WithOptions().NonClustered()
.Do();
}
}
}

View File

@@ -19,6 +19,7 @@ namespace Umbraco.Core.Persistence.Dtos
[Column("nodeId")]
[ForeignKey(typeof(ContentDto))]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_NodeId")]
public int NodeId { get; set; }
[Column("versionDate")] // TODO: db rename to 'updateDate'
@@ -30,8 +31,8 @@ namespace Umbraco.Core.Persistence.Dtos
[NullSetting(NullSetting = NullSettings.Null)]
public int? UserId { get => _userId == 0 ? null : _userId; set => _userId = value; } //return null if zero
// TODO: we need an index on this it is used almost always in querying and sorting
[Column("current")]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_Current")]
public bool Current { get; set; }
// about current:

View File

@@ -128,6 +128,7 @@
</Compile>
-->
<Compile Include="AssemblyExtensions.cs" />
<Compile Include="Migrations\Upgrade\V_8_6_0\MissingContentVersionsIndexes.cs" />
<Compile Include="SystemLock.cs" />
<Compile Include="Attempt.cs" />
<Compile Include="AttemptOfTResult.cs" />