feat(dal): Добавлена таблица Groups для возможности группировки Job

This commit is contained in:
Mikhail Kuznetsov
2025-06-11 11:14:27 +10:00
parent 0d08794636
commit 230dfd6f85
13 changed files with 8226 additions and 40 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,298 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class JobsUpdateAddJobGroupTbl : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_JobDetails_JobDetailsId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropTable(
name: "JobDetails",
schema: "job");
migrationBuilder.DropColumn(
name: "IsUmbrella",
schema: "job",
table: "Jobs");
migrationBuilder.RenameColumn(
name: "JobDetailsId",
schema: "job",
table: "FieldFilters",
newName: "UnitFilterId");
migrationBuilder.RenameIndex(
name: "IX_FieldFilters_JobDetailsId",
schema: "job",
table: "FieldFilters",
newName: "IX_FieldFilters_UnitFilterId");
migrationBuilder.AddColumn<Guid>(
name: "JobId",
table: "Templates",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "UnitId",
table: "Templates",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "GroupId",
schema: "job",
table: "Jobs",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<string>(
name: "WorkName",
schema: "job",
table: "Jobs",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "Groups",
schema: "job",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
GroupName = table.Column<string>(type: "text", nullable: false),
IsUmbrella = table.Column<bool>(type: "boolean", nullable: true),
ShortDescription = table.Column<string>(type: "text", nullable: false),
FullDescription = table.Column<string>(type: "text", nullable: false),
Solution = table.Column<string>(type: "text", nullable: false),
Duration = table.Column<string>(type: "text", nullable: false),
ReferenceDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Groups", x => x.Id);
},
comment: "Таблица описания групп работ, для реализации зонтиков");
migrationBuilder.CreateTable(
name: "JobUnitFilters",
schema: "job",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
UnitFilter = table.Column<string>(type: "text", nullable: false),
JobId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobUnitFilters", x => x.Id);
table.ForeignKey(
name: "FK_JobUnitFilters_Jobs_JobId",
column: x => x.JobId,
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП");
migrationBuilder.CreateIndex(
name: "IX_Templates_JobId",
table: "Templates",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_Templates_UnitId",
table: "Templates",
column: "UnitId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_GroupId",
schema: "job",
table: "Jobs",
column: "GroupId");
migrationBuilder.CreateIndex(
name: "IX_JobUnitFilters_JobId",
schema: "job",
table: "JobUnitFilters",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
column: "UnitFilterId",
principalSchema: "job",
principalTable: "JobUnitFilters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Jobs_Groups_GroupId",
schema: "job",
table: "Jobs",
column: "GroupId",
principalSchema: "job",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates",
column: "UnitId",
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropForeignKey(
name: "FK_Jobs_Groups_GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates");
migrationBuilder.DropTable(
name: "Groups",
schema: "job");
migrationBuilder.DropTable(
name: "JobUnitFilters",
schema: "job");
migrationBuilder.DropIndex(
name: "IX_Templates_JobId",
table: "Templates");
migrationBuilder.DropIndex(
name: "IX_Templates_UnitId",
table: "Templates");
migrationBuilder.DropIndex(
name: "IX_Jobs_GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropColumn(
name: "JobId",
table: "Templates");
migrationBuilder.DropColumn(
name: "UnitId",
table: "Templates");
migrationBuilder.DropColumn(
name: "GroupId",
schema: "job",
table: "Jobs");
migrationBuilder.DropColumn(
name: "WorkName",
schema: "job",
table: "Jobs");
migrationBuilder.RenameColumn(
name: "UnitFilterId",
schema: "job",
table: "FieldFilters",
newName: "JobDetailsId");
migrationBuilder.RenameIndex(
name: "IX_FieldFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
newName: "IX_FieldFilters_JobDetailsId");
migrationBuilder.AddColumn<bool>(
name: "IsUmbrella",
schema: "job",
table: "Jobs",
type: "boolean",
nullable: true);
migrationBuilder.CreateTable(
name: "JobDetails",
schema: "job",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
JobId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Duration = table.Column<string>(type: "text", nullable: false),
FullDescription = table.Column<string>(type: "text", nullable: false),
ReferenceDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ShortDescription = table.Column<string>(type: "text", nullable: false),
Solution = table.Column<string>(type: "text", nullable: false),
UnitFilter = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobDetails", x => x.Id);
table.ForeignKey(
name: "FK_JobDetails_Jobs_JobId",
column: x => x.JobId,
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП");
migrationBuilder.CreateIndex(
name: "IX_JobDetails_JobId",
schema: "job",
table: "JobDetails",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_JobDetails_JobDetailsId",
schema: "job",
table: "FieldFilters",
column: "JobDetailsId",
principalSchema: "job",
principalTable: "JobDetails",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,211 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class JobsUpdateMOCKData : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropForeignKey(
name: "FK_JobUnitFilters_Jobs_JobId",
schema: "job",
table: "JobUnitFilters");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates");
migrationBuilder.DropPrimaryKey(
name: "PK_JobUnitFilters",
schema: "job",
table: "JobUnitFilters");
migrationBuilder.RenameTable(
name: "JobUnitFilters",
schema: "job",
newName: "UnitFilters",
newSchema: "job");
migrationBuilder.RenameIndex(
name: "IX_JobUnitFilters_JobId",
schema: "job",
table: "UnitFilters",
newName: "IX_UnitFilters_JobId");
migrationBuilder.AlterColumn<Guid>(
name: "UnitId",
table: "Templates",
type: "uuid",
nullable: false,
defaultValue: new Guid("b4dfd71a-2b2f-414f-8409-4b9abd9c4d2c"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AlterColumn<Guid>(
name: "JobId",
table: "Templates",
type: "uuid",
nullable: false,
defaultValue: new Guid("ba05948b-b040-48cc-ab77-0accc9c223a0"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_UnitFilters",
schema: "job",
table: "UnitFilters",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_UnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
column: "UnitFilterId",
principalSchema: "job",
principalTable: "UnitFilters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates",
column: "UnitId",
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UnitFilters_Jobs_JobId",
schema: "job",
table: "UnitFilters",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FieldFilters_UnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_UnitFilters_Jobs_JobId",
schema: "job",
table: "UnitFilters");
migrationBuilder.DropPrimaryKey(
name: "PK_UnitFilters",
schema: "job",
table: "UnitFilters");
migrationBuilder.RenameTable(
name: "UnitFilters",
schema: "job",
newName: "JobUnitFilters",
newSchema: "job");
migrationBuilder.RenameIndex(
name: "IX_UnitFilters_JobId",
schema: "job",
table: "JobUnitFilters",
newName: "IX_JobUnitFilters_JobId");
migrationBuilder.AlterColumn<Guid>(
name: "UnitId",
table: "Templates",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AlterColumn<Guid>(
name: "JobId",
table: "Templates",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddPrimaryKey(
name: "PK_JobUnitFilters",
schema: "job",
table: "JobUnitFilters",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FieldFilters_JobUnitFilters_UnitFilterId",
schema: "job",
table: "FieldFilters",
column: "UnitFilterId",
principalSchema: "job",
principalTable: "JobUnitFilters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_JobUnitFilters_Jobs_JobId",
schema: "job",
table: "JobUnitFilters",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Jobs_JobId",
table: "Templates",
column: "JobId",
principalSchema: "job",
principalTable: "Jobs",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Templates_Units_UnitId",
table: "Templates",
column: "UnitId",
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id");
}
}
}

View File

@@ -1557,7 +1557,7 @@ namespace PARR.DAL.Migrations
b.Property<Guid>("FieldId")
.HasColumnType("uuid");
b.Property<Guid>("JobDetailsId")
b.Property<Guid>("UnitFilterId")
.HasColumnType("uuid");
b.Property<string>("ValueMask")
@@ -1568,7 +1568,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("FieldId");
b.HasIndex("JobDetailsId");
b.HasIndex("UnitFilterId");
b.ToTable("FieldFilters", "job", t =>
{
@@ -1588,8 +1588,8 @@ namespace PARR.DAL.Migrations
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<bool?>("IsUmbrella")
.HasColumnType("boolean");
b.Property<Guid>("GroupId")
.HasColumnType("uuid");
b.Property<int?>("MaxValueRelationships")
.HasColumnType("integer");
@@ -1607,8 +1607,14 @@ namespace PARR.DAL.Migrations
b.Property<Guid>("TnkId")
.HasColumnType("uuid");
b.Property<string>("WorkName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("GroupId");
b.HasIndex("TnkId");
b.ToTable("Jobs", "job", t =>
@@ -1617,7 +1623,7 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobDetails", b =>
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroup", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -1637,8 +1643,12 @@ namespace PARR.DAL.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("JobId")
.HasColumnType("uuid");
b.Property<string>("GroupName")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("IsUmbrella")
.HasColumnType("boolean");
b.Property<DateTimeOffset>("ReferenceDate")
.HasColumnType("timestamp with time zone");
@@ -1651,6 +1661,29 @@ namespace PARR.DAL.Migrations
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Groups", "job", t =>
{
t.HasComment("Таблица описания групп работ, для реализации зонтиков");
});
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobUnitFilter", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("JobId")
.HasColumnType("uuid");
b.Property<string>("UnitFilter")
.IsRequired()
.HasColumnType("text");
@@ -1659,7 +1692,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("JobId");
b.ToTable("JobDetails", "job", t =>
b.ToTable("UnitFilters", "job", t =>
{
t.HasComment("Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП");
});
@@ -2547,6 +2580,9 @@ namespace PARR.DAL.Migrations
b.Property<bool>("IsActiveTemplate")
.HasColumnType("boolean");
b.Property<Guid>("JobId")
.HasColumnType("uuid");
b.Property<DateTimeOffset?>("LastRun")
.HasColumnType("timestamp with time zone");
@@ -2560,15 +2596,22 @@ namespace PARR.DAL.Migrations
b.Property<string>("ScheduleEsppId")
.HasColumnType("text");
b.Property<Guid>("UnitId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ApplicationInWorkId");
b.HasIndex("HostId");
b.HasIndex("JobId");
b.HasIndex("Name")
.IsUnique();
b.HasIndex("UnitId");
b.ToTable("Templates");
});
@@ -3152,32 +3195,40 @@ namespace PARR.DAL.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Job.JobDetails", "JobDetails")
b.HasOne("PARR.DAL.Models.Job.JobUnitFilter", "UnitFilter")
.WithMany("fieldFilters")
.HasForeignKey("JobDetailsId")
.HasForeignKey("UnitFilterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Field");
b.Navigation("JobDetails");
b.Navigation("UnitFilter");
});
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
{
b.HasOne("PARR.DAL.Models.Job.JobGroup", "Group")
.WithMany("Job")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Tnk", "Tnk")
.WithMany()
.HasForeignKey("TnkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
b.Navigation("Tnk");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobDetails", b =>
modelBuilder.Entity("PARR.DAL.Models.Job.JobUnitFilter", b =>
{
b.HasOne("PARR.DAL.Models.Job.Job", "Job")
.WithMany("JobDetails")
.WithMany("UnitFilters")
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -3336,9 +3387,25 @@ namespace PARR.DAL.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Job.Job", "Job")
.WithMany()
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
.WithMany()
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ApplicationsInWork");
b.Navigation("Host");
b.Navigation("Job");
b.Navigation("Unit");
});
modelBuilder.Entity("PARR.DAL.Models.TemplateHistory", b =>
@@ -3564,10 +3631,15 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
{
b.Navigation("JobDetails");
b.Navigation("UnitFilters");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobDetails", b =>
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroup", b =>
{
b.Navigation("Job");
});
modelBuilder.Entity("PARR.DAL.Models.Job.JobUnitFilter", b =>
{
b.Navigation("fieldFilters");
});