using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PARR.DAL.Migrations { /// public partial class TblAddWorkGroup : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "WorkGroupId", table: "Hosts", type: "uuid", nullable: true); migrationBuilder.CreateTable( name: "WorkGroups", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_WorkGroups", x => x.Id); }); migrationBuilder.CreateTable( name: "AppInWorkInWorkGroups", columns: table => new { ApplicationsInWorkId = table.Column(type: "uuid", nullable: false), WorkGroupId = table.Column(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"); } /// 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"); } } }