feat(dal, domain): Для таблице UnitInTemplates добавлена связь с UnitFieldValues. В таблице Templates убраны значения по умолчанию для поле JobId, UnitId.

This commit is contained in:
Mikhail Trubnikov
2026-05-12 16:34:31 +10:00
parent 97964111c3
commit e5900be547
13 changed files with 9618 additions and 1808 deletions

View File

@@ -65,7 +65,7 @@ namespace PARR.DAL.Context
public DbSet<Order> Orders { get; set; }
public DbSet<OrderStatus> OrderStatuses { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Domain.Entities.User> Users { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<UsersInRole> UsersInRoles { get; set; }
@@ -135,6 +135,11 @@ namespace PARR.DAL.Context
var dateCreated = new DateTimeOffset(2023, 05, 01, 0, 0, 0, new TimeSpan(0));
//Задать значение по умолчанию
//modelBuilder.Entity<UnitsInTemplate>()
// .Property(t => t.UnitFieldValueId)
// .HasDefaultValue(new Guid("d6485475-d4c5-47f0-a48f-b364a6321cc4"));
#region Unit
//Добавляем ограничение по имени ЭК. нельзя писать прописными!!!
modelBuilder.Entity<Unit>(f =>
@@ -148,7 +153,8 @@ namespace PARR.DAL.Context
#region UnitsInTemplate
modelBuilder.Entity<UnitsInTemplate>()
.HasKey(t => new { t.TemplateId, t.UnitId });
.HasKey(t => new { t.TemplateId, t.UnitId, t.UnitFieldValueId });
#endregion
#region JobGroupType
@@ -569,9 +575,9 @@ namespace PARR.DAL.Context
#region TaskType
modelBuilder.Entity<TaskType>(f =>
modelBuilder.Entity<Domain.Entities.TaskEntities.TaskType>(f =>
{
f.HasData(new TaskType[]
f.HasData(new Domain.Entities.TaskEntities.TaskType[]
{
new() { Code = TaskTypeEnum.Workload, Name = TaskTypeEnum.Workload.ToString(), Description = "Формирование данных для отчетности - Загруженность", MaxRetries = 2, IsSingleton=true, MaxExecutionTimeMinutes=60, RetentionDays=90 }
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,96 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblUnitsInTemplateAddUnitFieldValueId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_UnitsInTemplates",
schema: "job",
table: "UnitsInTemplates");
migrationBuilder.AddColumn<Guid>(
name: "UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates",
type: "uuid",
nullable: false,
defaultValue: new Guid("d6485475-d4c5-47f0-a48f-b364a6321cc4"));
migrationBuilder.AddPrimaryKey(
name: "PK_UnitsInTemplates",
schema: "job",
table: "UnitsInTemplates",
columns: new[] { "TemplateId", "UnitId", "UnitFieldValueId" });
migrationBuilder.UpdateData(
schema: "task",
table: "Types",
keyColumn: "Code",
keyValue: 0,
column: "MaxExecutionTimeMinutes",
value: 60);
migrationBuilder.CreateIndex(
name: "IX_UnitsInTemplates_UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates",
column: "UnitFieldValueId");
migrationBuilder.AddForeignKey(
name: "FK_UnitsInTemplates_FieldValues_UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates",
column: "UnitFieldValueId",
principalSchema: "unit",
principalTable: "FieldValues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UnitsInTemplates_FieldValues_UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates");
migrationBuilder.DropPrimaryKey(
name: "PK_UnitsInTemplates",
schema: "job",
table: "UnitsInTemplates");
migrationBuilder.DropIndex(
name: "IX_UnitsInTemplates_UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates");
migrationBuilder.DropColumn(
name: "UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates");
migrationBuilder.AddPrimaryKey(
name: "PK_UnitsInTemplates",
schema: "job",
table: "UnitsInTemplates",
columns: new[] { "TemplateId", "UnitId" });
migrationBuilder.UpdateData(
schema: "task",
table: "Types",
keyColumn: "Code",
keyValue: 0,
column: "MaxExecutionTimeMinutes",
value: 30);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblUnitsInTemplateAddUnitFieldValueIdUnsetDefault : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<Guid>(
name: "UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates",
type: "uuid",
nullable: false,
oldClrType: typeof(Guid),
oldType: "uuid",
oldDefaultValue: new Guid("d6485475-d4c5-47f0-a48f-b364a6321cc4"));
migrationBuilder.AlterColumn<Guid>(
name: "JobId",
schema: "public",
table: "Templates",
type: "uuid",
nullable: false,
oldClrType: typeof(Guid),
oldType: "uuid",
oldDefaultValue: new Guid("ba05948b-b040-48cc-ab77-0accc9c223a0"));
migrationBuilder.AlterColumn<Guid>(
name: "UnitId",
schema: "public",
table: "Templates",
type: "uuid",
nullable: false,
oldClrType: typeof(Guid),
oldType: "uuid",
oldDefaultValue: new Guid("b4dfd71a-2b2f-414f-8409-4b9abd9c4d2c"));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<Guid>(
name: "UnitFieldValueId",
schema: "job",
table: "UnitsInTemplates",
type: "uuid",
nullable: false,
defaultValue: new Guid("d6485475-d4c5-47f0-a48f-b364a6321cc4"),
oldClrType: typeof(Guid),
oldType: "uuid");
}
}
}

File diff suppressed because it is too large Load Diff