feat(dal): Индексы для RobotHistory

This commit is contained in:
Mikhail Trubnikov
2026-04-15 10:48:21 +10:00
parent a93e8de4b0
commit c3b4c45892
8 changed files with 7679 additions and 6 deletions

View File

@@ -22,7 +22,7 @@
<PackageReference Include="Elastic.CommonSchema.Serilog" Version="8.6.1" /> <PackageReference Include="Elastic.CommonSchema.Serilog" Version="8.6.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.2" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblRobotHistoryAddIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_RobotHistories_HistoryLevel",
table: "RobotHistories");
migrationBuilder.DropIndex(
name: "IX_RobotHistories_RobotConfigurationId",
table: "RobotHistories");
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_HistoryLevel_DateCreated",
table: "RobotHistories",
columns: new[] { "HistoryLevel", "DateCreated" },
descending: new[] { false, true });
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_RobotConfigurationId_DateCreated",
table: "RobotHistories",
columns: new[] { "RobotConfigurationId", "DateCreated" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_RobotHistories_HistoryLevel_DateCreated",
table: "RobotHistories");
migrationBuilder.DropIndex(
name: "IX_RobotHistories_RobotConfigurationId_DateCreated",
table: "RobotHistories");
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_HistoryLevel",
table: "RobotHistories",
column: "HistoryLevel");
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_RobotConfigurationId",
table: "RobotHistories",
column: "RobotConfigurationId");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblRobotHistoryAddIndex2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_RobotHistories_DateCreated",
table: "RobotHistories",
column: "DateCreated");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_RobotHistories_DateCreated",
table: "RobotHistories");
}
}
}

View File

@@ -1900,12 +1900,15 @@ namespace PARR.DAL.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("HistoryLevel"); b.HasIndex("DateCreated");
b.HasIndex("RobotConfigurationId");
b.HasIndex("TaskStatusCode"); b.HasIndex("TaskStatusCode");
b.HasIndex("HistoryLevel", "DateCreated")
.IsDescending(false, true);
b.HasIndex("RobotConfigurationId", "DateCreated");
b.ToTable("RobotHistories"); b.ToTable("RobotHistories");
}); });

View File

@@ -1,9 +1,13 @@
using PARR.Domain.Entities.Base; using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models namespace PARR.DAL.Models
{ {
[Table("RobotHistories")] [Table("RobotHistories")]
[Index(nameof(HistoryLevel), nameof(DateCreated), IsDescending = new[] { false, true })]
[Index(nameof(RobotConfigurationId), nameof(DateCreated))]
[Index(nameof(DateCreated))]
public class RobotHistory : IBaseEntity public class RobotHistory : IBaseEntity
{ {
public Guid Id { get; set; } public Guid Id { get; set; }

View File

@@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.20">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>