feat(dal): Созданы таблицы JobGroupTypes+UnitsInTemplates, обновлен ключ уникального индекса шаблонов

This commit is contained in:
Mikhail Kuznetsov
2025-11-14 14:48:56 +10:00
parent 334595e81c
commit 48c8741395
19 changed files with 12199 additions and 16 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,103 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblJobGroupTypeCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "isParentRelationships",
schema: "job",
table: "Jobs",
newName: "IsParentRelationships");
migrationBuilder.AddColumn<Guid>(
name: "GroupTypeId",
schema: "job",
table: "Groups",
type: "uuid",
nullable: false,
defaultValue: new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"));
migrationBuilder.CreateTable(
name: "GroupTypes",
schema: "job",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Code = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GroupTypes", x => x.Id);
},
comment: "Таблица типов групп работ");
migrationBuilder.InsertData(
schema: "job",
table: "GroupTypes",
columns: new[] { "Id", "Code", "DateCreated", "Name" },
values: new object[,]
{
{ new Guid("318625e5-f833-436a-99df-2a382a1e71c7"), 2, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Group" },
{ new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"), 0, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Simple" },
{ new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"), 1, new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Umbrella" }
});
migrationBuilder.CreateIndex(
name: "IX_Groups_GroupTypeId",
schema: "job",
table: "Groups",
column: "GroupTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Groups_GroupTypes_GroupTypeId",
schema: "job",
table: "Groups",
column: "GroupTypeId",
principalSchema: "job",
principalTable: "GroupTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Groups_GroupTypes_GroupTypeId",
schema: "job",
table: "Groups");
migrationBuilder.DropTable(
name: "GroupTypes",
schema: "job");
migrationBuilder.DropIndex(
name: "IX_Groups_GroupTypeId",
schema: "job",
table: "Groups");
migrationBuilder.DropColumn(
name: "GroupTypeId",
schema: "job",
table: "Groups");
migrationBuilder.RenameColumn(
name: "IsParentRelationships",
schema: "job",
table: "Jobs",
newName: "isParentRelationships");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblUnitsInTemplates : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Templates_Name",
table: "Templates");
migrationBuilder.AddColumn<int>(
name: "Index",
table: "Templates",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsUnused",
table: "Templates",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "UnitsInTemplates",
schema: "job",
columns: table => new
{
TemplateId = table.Column<Guid>(type: "uuid", nullable: false),
UnitId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UnitsInTemplates", x => new { x.TemplateId, x.UnitId });
table.ForeignKey(
name: "FK_UnitsInTemplates_Templates_TemplateId",
column: x => x.TemplateId,
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UnitsInTemplates_Units_UnitId",
column: x => x.UnitId,
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица связи ЭК в шаблонах");
migrationBuilder.CreateIndex(
name: "IX_Templates_Name_Index",
table: "Templates",
columns: new[] { "Name", "Index" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UnitsInTemplates_UnitId",
schema: "job",
table: "UnitsInTemplates",
column: "UnitId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UnitsInTemplates",
schema: "job");
migrationBuilder.DropIndex(
name: "IX_Templates_Name_Index",
table: "Templates");
migrationBuilder.DropColumn(
name: "Index",
table: "Templates");
migrationBuilder.DropColumn(
name: "IsUnused",
table: "Templates");
migrationBuilder.CreateIndex(
name: "IX_Templates_Name",
table: "Templates",
column: "Name",
unique: true);
}
}
}

View File

@@ -1557,6 +1557,9 @@ namespace PARR.DAL.Migrations
b.Property<Guid>("GroupId")
.HasColumnType("uuid");
b.Property<bool?>("IsParentRelationships")
.HasColumnType("boolean");
b.Property<int?>("MaxValueRelationships")
.HasColumnType("integer");
@@ -1582,9 +1585,6 @@ namespace PARR.DAL.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("isParentRelationships")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("GroupId");
@@ -1660,6 +1660,9 @@ namespace PARR.DAL.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("GroupTypeId")
.HasColumnType("uuid");
b.Property<bool>("IsAgent")
.HasColumnType("boolean");
@@ -1686,12 +1689,61 @@ namespace PARR.DAL.Migrations
b.HasKey("Id");
b.HasIndex("GroupTypeId");
b.ToTable("Groups", "job", t =>
{
t.HasComment("Таблица описания групп работ, для реализации зонтиков");
});
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroupType", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Code")
.HasColumnType("integer");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("GroupTypes", "job", t =>
{
t.HasComment("Таблица типов групп работ");
});
b.HasData(
new
{
Id = new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"),
Code = 0,
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Name = "Simple"
},
new
{
Id = new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"),
Code = 1,
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Name = "Umbrella"
},
new
{
Id = new Guid("318625e5-f833-436a-99df-2a382a1e71c7"),
Code = 2,
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Name = "Group"
});
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobRelationshipFilter", b =>
{
b.Property<Guid>("UnitFilterId")
@@ -2619,6 +2671,9 @@ namespace PARR.DAL.Migrations
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Index")
.HasColumnType("integer");
b.Property<string>("InitiatorComment")
.HasColumnType("text");
@@ -2634,6 +2689,9 @@ namespace PARR.DAL.Migrations
b.Property<bool>("IsActiveTemplate")
.HasColumnType("boolean");
b.Property<bool>("IsUnused")
.HasColumnType("boolean");
b.Property<Guid>("JobId")
.HasColumnType("uuid");
@@ -2657,11 +2715,11 @@ namespace PARR.DAL.Migrations
b.HasIndex("JobId");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("UnitId");
b.HasIndex("Name", "Index")
.IsUnique();
b.ToTable("Templates");
});
@@ -2925,6 +2983,27 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.UnitsInTemplate", b =>
{
b.Property<Guid>("TemplateId")
.HasColumnType("uuid");
b.Property<Guid>("UnitId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.HasKey("TemplateId", "UnitId");
b.HasIndex("UnitId");
b.ToTable("UnitsInTemplates", "job", t =>
{
t.HasComment("Таблица связи ЭК в шаблонах");
});
});
modelBuilder.Entity("PARR.DAL.Models.User", b =>
{
b.Property<Guid>("Id")
@@ -3280,6 +3359,17 @@ namespace PARR.DAL.Migrations
b.Navigation("UnitFilter");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroup", b =>
{
b.HasOne("PARR.DAL.Models.Job.JobGroupType", "GroupType")
.WithMany("JobGroups")
.HasForeignKey("GroupTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupType");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobRelationshipFilter", b =>
{
b.HasOne("PARR.DAL.Models.Unit.UnitField", "UnitField")
@@ -3572,6 +3662,25 @@ namespace PARR.DAL.Migrations
b.Navigation("Value");
});
modelBuilder.Entity("PARR.DAL.Models.UnitsInTemplate", b =>
{
b.HasOne("PARR.DAL.Models.Template", "Template")
.WithMany("UnitsInTemplate")
.HasForeignKey("TemplateId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
.WithMany("TemplatesInUnit")
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Template");
b.Navigation("Unit");
});
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
{
b.HasOne("PARR.DAL.Models.Role", "Role")
@@ -3695,6 +3804,11 @@ namespace PARR.DAL.Migrations
b.Navigation("Jobs");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroupType", b =>
{
b.Navigation("JobGroups");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobUnitFilter", b =>
{
b.Navigation("FieldFilters");
@@ -3779,6 +3893,8 @@ namespace PARR.DAL.Migrations
b.Navigation("RobotConfigurations");
b.Navigation("TemplateHistories");
b.Navigation("UnitsInTemplate");
});
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
@@ -3794,6 +3910,8 @@ namespace PARR.DAL.Migrations
b.Navigation("Templates");
b.Navigation("TemplatesInUnit");
b.Navigation("UnitFields");
b.Navigation("UnitValues");