98 lines
3.5 KiB
C#
98 lines
3.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace PARR.DAL.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class TblAddWorkGroup : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "WorkGroupId",
|
|
table: "Hosts",
|
|
type: "uuid",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "WorkGroups",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WorkGroups", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AppInWorkInWorkGroups",
|
|
columns: table => new
|
|
{
|
|
ApplicationsInWorkId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AppInWorkInWorkGroups", x => new { x.ApplicationsInWorkId, x.WorkGroupId });
|
|
table.ForeignKey(
|
|
name: "FK_AppInWorkInWorkGroups_ApplicationsInWorks_ApplicationsInWor~",
|
|
column: x => x.ApplicationsInWorkId,
|
|
principalTable: "ApplicationsInWorks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_AppInWorkInWorkGroups_WorkGroups_WorkGroupId",
|
|
column: x => x.WorkGroupId,
|
|
principalTable: "WorkGroups",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Hosts_WorkGroupId",
|
|
table: "Hosts",
|
|
column: "WorkGroupId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AppInWorkInWorkGroups_WorkGroupId",
|
|
table: "AppInWorkInWorkGroups",
|
|
column: "WorkGroupId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Hosts_WorkGroups_WorkGroupId",
|
|
table: "Hosts",
|
|
column: "WorkGroupId",
|
|
principalTable: "WorkGroups",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Hosts_WorkGroups_WorkGroupId",
|
|
table: "Hosts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AppInWorkInWorkGroups");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "WorkGroups");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Hosts_WorkGroupId",
|
|
table: "Hosts");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "WorkGroupId",
|
|
table: "Hosts");
|
|
}
|
|
}
|
|
}
|