feat(aihitRelationshipsSyncer): Реализована логика синхронизации связей между Unit+CI/CD
This commit is contained in:
@@ -78,6 +78,8 @@ namespace PARR.DAL.Context
|
||||
|
||||
public DbSet<UnitFieldInUnitFieldValue> UnitFieldInUnitFieldValues { get; set; }
|
||||
|
||||
public DbSet<UnitInUnit> UnitInUnits { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
3534
PARR.DAL/Migrations/20250522042529_tblUnitInUnits.Designer.cs
generated
Normal file
3534
PARR.DAL/Migrations/20250522042529_tblUnitInUnits.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
59
PARR.DAL/Migrations/20250522042529_tblUnitInUnits.cs
Normal file
59
PARR.DAL/Migrations/20250522042529_tblUnitInUnits.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblUnitInUnits : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UnitInUnits",
|
||||
schema: "unit",
|
||||
columns: table => new
|
||||
{
|
||||
ParentUnitId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ChildUnitId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateSynced = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UnitInUnits", x => new { x.ParentUnitId, x.ChildUnitId });
|
||||
table.ForeignKey(
|
||||
name: "FK_UnitInUnits_Units_ChildUnitId",
|
||||
column: x => x.ChildUnitId,
|
||||
principalSchema: "unit",
|
||||
principalTable: "Units",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_UnitInUnits_Units_ParentUnitId",
|
||||
column: x => x.ParentUnitId,
|
||||
principalSchema: "unit",
|
||||
principalTable: "Units",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Таблица связей иерархии между ЭК");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UnitInUnits_ChildUnitId",
|
||||
schema: "unit",
|
||||
table: "UnitInUnits",
|
||||
column: "ChildUnitId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "UnitInUnits",
|
||||
schema: "unit");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2651,6 +2651,30 @@ namespace PARR.DAL.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInUnit", b =>
|
||||
{
|
||||
b.Property<Guid>("ParentUnitId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ChildUnitId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateSynced")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("ParentUnitId", "ChildUnitId");
|
||||
|
||||
b.HasIndex("ChildUnitId");
|
||||
|
||||
b.ToTable("UnitInUnits", "unit", t =>
|
||||
{
|
||||
t.HasComment("Таблица связей иерархии между ЭК");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInValue", b =>
|
||||
{
|
||||
b.Property<Guid>("UnitId")
|
||||
@@ -3213,6 +3237,25 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("UnitField");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInUnit", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.Unit", "Child")
|
||||
.WithMany("Parents")
|
||||
.HasForeignKey("ChildUnitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Unit.Unit", "Parent")
|
||||
.WithMany("Childs")
|
||||
.HasForeignKey("ParentUnitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Child");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitInValue", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.UnitField", "Field")
|
||||
@@ -3441,6 +3484,10 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.Unit", b =>
|
||||
{
|
||||
b.Navigation("Childs");
|
||||
|
||||
b.Navigation("Parents");
|
||||
|
||||
b.Navigation("UnitFields");
|
||||
|
||||
b.Navigation("UnitValues");
|
||||
|
||||
@@ -31,5 +31,18 @@ namespace PARR.DAL.Models.Unit
|
||||
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
|
||||
|
||||
public ICollection<UnitInValue> UnitValues { get; set; } = new HashSet<UnitInValue>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить всех родителей
|
||||
/// </summary>
|
||||
[InverseProperty(nameof(UnitInUnit.ChildUnit))]
|
||||
public ICollection<UnitInUnit> ParentUnits { get; set; } = new HashSet<UnitInUnit>();
|
||||
|
||||
/// <summary>
|
||||
/// Получить детей
|
||||
/// </summary>
|
||||
[InverseProperty(nameof(UnitInUnit.ParentUnit))]
|
||||
public ICollection<UnitInUnit> ChildUnits { get; set; } = new HashSet<UnitInUnit>();
|
||||
}
|
||||
}
|
||||
|
||||
30
PARR.DAL/Models/Unit/UnitInUnit.cs
Normal file
30
PARR.DAL/Models/Unit/UnitInUnit.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.DAL.Context;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// Связи иерархии между ЭК
|
||||
/// </summary>
|
||||
[Table("UnitInUnits", Schema = DataContextSettings.Unit)]
|
||||
[Comment("Таблица связей иерархии между ЭК")]
|
||||
[PrimaryKey(nameof(ParentUnitId), nameof(ChildUnitId))]
|
||||
public class UnitInUnit
|
||||
{
|
||||
public Guid ParentUnitId { get; set; }
|
||||
|
||||
public Guid ChildUnitId { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
public DateTimeOffset? DateSynced { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(ParentUnitId))]
|
||||
public Unit? ParentUnit { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ChildUnitId))]
|
||||
public Unit? ChildUnit { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user