60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|