feat(dal,aihitloader): Создали таблицы схемы Units и сервисы к ним.

This commit is contained in:
Mikhail Kuznetsov
2025-05-14 15:13:30 +10:00
parent a89e7f7b86
commit b03af638f6
27 changed files with 4361 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,239 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class units : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "unit");
migrationBuilder.CreateTable(
name: "Fields",
schema: "unit",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
AihitName = table.Column<string>(type: "text", nullable: false),
EsppName = table.Column<string>(type: "text", nullable: true),
DisplayName = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Fields", x => x.Id);
},
comment: "Справочник полей ЭК");
migrationBuilder.CreateTable(
name: "FieldValues",
schema: "unit",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Value = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_FieldValues", x => x.Id);
},
comment: "Значения полей ЭК");
migrationBuilder.CreateTable(
name: "Units",
schema: "unit",
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),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Units", x => x.Id);
},
comment: "Таблица с ЭК");
migrationBuilder.CreateTable(
name: "FieldInFieldValues",
schema: "unit",
columns: table => new
{
FieldId = table.Column<Guid>(type: "uuid", nullable: false),
FieldValueId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FieldInFieldValues", x => new { x.FieldId, x.FieldValueId });
table.ForeignKey(
name: "FK_FieldInFieldValues_FieldValues_FieldValueId",
column: x => x.FieldValueId,
principalSchema: "unit",
principalTable: "FieldValues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_FieldInFieldValues_Fields_FieldId",
column: x => x.FieldId,
principalSchema: "unit",
principalTable: "Fields",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Значения полей ЭК");
migrationBuilder.CreateTable(
name: "UnitInFields",
schema: "unit",
columns: table => new
{
UnitId = table.Column<Guid>(type: "uuid", nullable: false),
FieldId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UnitInFields", x => new { x.UnitId, x.FieldId });
table.ForeignKey(
name: "FK_UnitInFields_Fields_FieldId",
column: x => x.FieldId,
principalSchema: "unit",
principalTable: "Fields",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UnitInFields_Units_UnitId",
column: x => x.UnitId,
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Справочник полей ЭК");
migrationBuilder.CreateTable(
name: "UnitInValues",
schema: "unit",
columns: table => new
{
UnitId = table.Column<Guid>(type: "uuid", nullable: false),
FieldId = table.Column<Guid>(type: "uuid", nullable: false),
VlaueId = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_UnitInValues", x => new { x.UnitId, x.FieldId });
table.ForeignKey(
name: "FK_UnitInValues_FieldValues_VlaueId",
column: x => x.VlaueId,
principalSchema: "unit",
principalTable: "FieldValues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UnitInValues_Fields_FieldId",
column: x => x.FieldId,
principalSchema: "unit",
principalTable: "Fields",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UnitInValues_Units_UnitId",
column: x => x.UnitId,
principalSchema: "unit",
principalTable: "Units",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "Таблица связи ЭК с полями и со значениями");
migrationBuilder.CreateIndex(
name: "IX_FieldInFieldValues_FieldValueId",
schema: "unit",
table: "FieldInFieldValues",
column: "FieldValueId");
migrationBuilder.CreateIndex(
name: "IX_Fields_AihitName",
schema: "unit",
table: "Fields",
column: "AihitName");
migrationBuilder.CreateIndex(
name: "IX_Fields_EsppName",
schema: "unit",
table: "Fields",
column: "EsppName");
migrationBuilder.CreateIndex(
name: "IX_FieldValues_Value",
schema: "unit",
table: "FieldValues",
column: "Value");
migrationBuilder.CreateIndex(
name: "IX_UnitInFields_FieldId",
schema: "unit",
table: "UnitInFields",
column: "FieldId");
migrationBuilder.CreateIndex(
name: "IX_UnitInValues_FieldId",
schema: "unit",
table: "UnitInValues",
column: "FieldId");
migrationBuilder.CreateIndex(
name: "IX_UnitInValues_VlaueId",
schema: "unit",
table: "UnitInValues",
column: "VlaueId");
migrationBuilder.CreateIndex(
name: "IX_Units_Name",
schema: "unit",
table: "Units",
column: "Name",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FieldInFieldValues",
schema: "unit");
migrationBuilder.DropTable(
name: "UnitInFields",
schema: "unit");
migrationBuilder.DropTable(
name: "UnitInValues",
schema: "unit");
migrationBuilder.DropTable(
name: "FieldValues",
schema: "unit");
migrationBuilder.DropTable(
name: "Fields",
schema: "unit");
migrationBuilder.DropTable(
name: "Units",
schema: "unit");
}
}
}

View File

@@ -2528,6 +2528,157 @@ namespace PARR.DAL.Migrations
b.ToTable("Tnks");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.Unit", 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<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Units", "unit", t =>
{
t.HasComment("Таблица с ЭК");
});
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitField", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AihitName")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<string>("EsppName")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("AihitName");
b.HasIndex("EsppName");
b.ToTable("Fields", "unit", t =>
{
t.HasComment("Справочник полей ЭК");
});
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitFieldInUnitFieldValue", b =>
{
b.Property<Guid>("FieldId")
.HasColumnType("uuid");
b.Property<Guid>("FieldValueId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.HasKey("FieldId", "FieldValueId");
b.HasIndex("FieldValueId");
b.ToTable("FieldInFieldValues", "unit", t =>
{
t.HasComment("Значения полей ЭК");
});
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitFieldValue", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Value");
b.ToTable("FieldValues", "unit", t =>
{
t.HasComment("Значения полей ЭК");
});
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInField", b =>
{
b.Property<Guid>("UnitId")
.HasColumnType("uuid");
b.Property<Guid>("FieldId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.HasKey("UnitId", "FieldId");
b.HasIndex("FieldId");
b.ToTable("UnitInFields", "unit", t =>
{
t.HasComment("Справочник полей ЭК");
});
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInValue", b =>
{
b.Property<Guid>("UnitId")
.HasColumnType("uuid");
b.Property<Guid>("FieldId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("DateModified")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("VlaueId")
.HasColumnType("uuid");
b.HasKey("UnitId", "FieldId");
b.HasIndex("FieldId");
b.HasIndex("VlaueId");
b.ToTable("UnitInValues", "unit", t =>
{
t.HasComment("Таблица связи ЭК с полями и со значениями");
});
});
modelBuilder.Entity("PARR.DAL.Models.User", b =>
{
b.Property<Guid>("Id")
@@ -3023,6 +3174,71 @@ namespace PARR.DAL.Migrations
b.Navigation("Subprocess");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitFieldInUnitFieldValue", b =>
{
b.HasOne("PARR.DAL.Models.Unit.UnitField", "Field")
.WithMany("FieldValues")
.HasForeignKey("FieldId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.UnitFieldValue", "FieldValue")
.WithMany("FieldValues")
.HasForeignKey("FieldValueId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Field");
b.Navigation("FieldValue");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInField", b =>
{
b.HasOne("PARR.DAL.Models.Unit.UnitField", "UnitField")
.WithMany("Units")
.HasForeignKey("FieldId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
.WithMany("UnitFields")
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Unit");
b.Navigation("UnitField");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInValue", b =>
{
b.HasOne("PARR.DAL.Models.Unit.UnitField", "Field")
.WithMany("UnitInValues")
.HasForeignKey("FieldId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
.WithMany("UnitInValues")
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Unit.UnitFieldValue", "Value")
.WithMany("UnitInValues")
.HasForeignKey("VlaueId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Field");
b.Navigation("Unit");
b.Navigation("Value");
});
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
{
b.HasOne("PARR.DAL.Models.Role", "Role")
@@ -3222,6 +3438,29 @@ namespace PARR.DAL.Migrations
b.Navigation("Works");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.Unit", b =>
{
b.Navigation("UnitFields");
b.Navigation("UnitInValues");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitField", b =>
{
b.Navigation("FieldValues");
b.Navigation("UnitInValues");
b.Navigation("Units");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitFieldValue", b =>
{
b.Navigation("FieldValues");
b.Navigation("UnitInValues");
});
modelBuilder.Entity("PARR.DAL.Models.User", b =>
{
b.Navigation("Roles");