Связь Hosts & templates. Переделал респонс для get all templates
This commit is contained in:
1330
PARR.DAL/Migrations/20230919052753_TblHostsRelToTemplate.Designer.cs
generated
Normal file
1330
PARR.DAL/Migrations/20230919052753_TblHostsRelToTemplate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
81
PARR.DAL/Migrations/20230919052753_TblHostsRelToTemplate.cs
Normal file
81
PARR.DAL/Migrations/20230919052753_TblHostsRelToTemplate.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TblHostsRelToTemplate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "HostId",
|
||||
table: "Templates",
|
||||
type: "uuid",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "HostId",
|
||||
table: "Hosts",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Templates_HostId",
|
||||
table: "Templates",
|
||||
column: "HostId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Hosts_HostId",
|
||||
table: "Hosts",
|
||||
column: "HostId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Hosts_Hosts_HostId",
|
||||
table: "Hosts",
|
||||
column: "HostId",
|
||||
principalTable: "Hosts",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Templates_Hosts_HostId",
|
||||
table: "Templates",
|
||||
column: "HostId",
|
||||
principalTable: "Hosts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Hosts_Hosts_HostId",
|
||||
table: "Hosts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Templates_Hosts_HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Templates_HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Hosts_HostId",
|
||||
table: "Hosts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HostId",
|
||||
table: "Hosts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,6 +391,9 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("HostId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("IP")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@@ -406,6 +409,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.ToTable("Hosts");
|
||||
});
|
||||
|
||||
@@ -556,6 +561,9 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("HostId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -570,6 +578,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("ApplicationInWorkId");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
@@ -1055,6 +1065,13 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Host", null)
|
||||
.WithMany("Hosts")
|
||||
.HasForeignKey("HostId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Process", "Process")
|
||||
@@ -1074,6 +1091,12 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Host", "Host")
|
||||
.WithMany()
|
||||
.HasForeignKey("HostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.StatusTemplate", "StatusTemplate")
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("StatusCode")
|
||||
@@ -1082,6 +1105,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.Navigation("ApplicationsInWork");
|
||||
|
||||
b.Navigation("Host");
|
||||
|
||||
b.Navigation("StatusTemplate");
|
||||
});
|
||||
|
||||
@@ -1226,6 +1251,8 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInHosts");
|
||||
|
||||
b.Navigation("Hosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Process", b =>
|
||||
|
||||
@@ -29,5 +29,7 @@ namespace PARR.DAL.Models
|
||||
|
||||
|
||||
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
||||
|
||||
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +32,11 @@ namespace PARR.DAL.Models
|
||||
[ForeignKey(nameof(ApplicationInWorkId))]
|
||||
public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
|
||||
|
||||
public Guid HostId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(HostId))]
|
||||
public Host? Host { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user