using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Data.SeaHavenIndustries.Migrations { /// public partial class changesinaddwork : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Comments_WorkerOrder_WorkerOrderId", table: "Comments"); migrationBuilder.DropForeignKey( name: "FK_Template_AspNetUsers_AssignTo", table: "Template"); migrationBuilder.DropForeignKey( name: "FK_Template_Categories_CategoryId", table: "Template"); migrationBuilder.DropForeignKey( name: "FK_Template_Locations_LocationId", table: "Template"); migrationBuilder.DropTable( name: "WorkerOrder"); migrationBuilder.DropPrimaryKey( name: "PK_Template", table: "Template"); migrationBuilder.RenameTable( name: "Template", newName: "Templates"); migrationBuilder.RenameIndex( name: "IX_Template_LocationId", table: "Templates", newName: "IX_Templates_LocationId"); migrationBuilder.RenameIndex( name: "IX_Template_CategoryId", table: "Templates", newName: "IX_Templates_CategoryId"); migrationBuilder.RenameIndex( name: "IX_Template_AssignTo", table: "Templates", newName: "IX_Templates_AssignTo"); migrationBuilder.AddPrimaryKey( name: "PK_Templates", table: "Templates", column: "Id"); migrationBuilder.CreateTable( name: "workOrders", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), WorkerOrderNumber = table.Column(type: "nvarchar(max)", nullable: true), WorkerOrderTitle = table.Column(type: "nvarchar(max)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true), PO = table.Column(type: "nvarchar(max)", nullable: true), TT = table.Column(type: "nvarchar(max)", nullable: true), POC = table.Column(type: "nvarchar(max)", nullable: true), AssignTo = table.Column(type: "nvarchar(450)", nullable: true), DueDate = table.Column(type: "datetime2", nullable: true), Priority = table.Column(type: "nvarchar(max)", nullable: true), Status = table.Column(type: "nvarchar(max)", nullable: true), LocationId = table.Column(type: "int", nullable: true), CategoryId = table.Column(type: "int", nullable: true), Attachments = table.Column(type: "nvarchar(max)", nullable: true), BeforPhotoIssue = table.Column(type: "nvarchar(max)", nullable: true), BeforPhotoAttachment = table.Column(type: "nvarchar(max)", nullable: true), AfterPhotoIssue = table.Column(type: "nvarchar(max)", nullable: true), AfterPhotoAttachment = table.Column(type: "nvarchar(max)", nullable: true), SignOffName = table.Column(type: "nvarchar(max)", nullable: true), SignOffSignature = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: true), createdby = table.Column(type: "nvarchar(max)", nullable: true), DeleterUserId = table.Column(type: "nvarchar(max)", nullable: true), DeletionTime = table.Column(type: "datetime2", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: true), LastModificationTime = table.Column(type: "datetime2", nullable: true), LastModifierUserId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_workOrders", x => x.Id); table.ForeignKey( name: "FK_workOrders_AspNetUsers_AssignTo", column: x => x.AssignTo, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_workOrders_Categories_CategoryId", column: x => x.CategoryId, principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_workOrders_Locations_LocationId", column: x => x.LocationId, principalTable: "Locations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_workOrders_AssignTo", table: "workOrders", column: "AssignTo"); migrationBuilder.CreateIndex( name: "IX_workOrders_CategoryId", table: "workOrders", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_workOrders_LocationId", table: "workOrders", column: "LocationId"); migrationBuilder.AddForeignKey( name: "FK_Comments_workOrders_WorkerOrderId", table: "Comments", column: "WorkerOrderId", principalTable: "workOrders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Templates_AspNetUsers_AssignTo", table: "Templates", column: "AssignTo", principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Templates_Categories_CategoryId", table: "Templates", column: "CategoryId", principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Templates_Locations_LocationId", table: "Templates", column: "LocationId", principalTable: "Locations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Comments_workOrders_WorkerOrderId", table: "Comments"); migrationBuilder.DropForeignKey( name: "FK_Templates_AspNetUsers_AssignTo", table: "Templates"); migrationBuilder.DropForeignKey( name: "FK_Templates_Categories_CategoryId", table: "Templates"); migrationBuilder.DropForeignKey( name: "FK_Templates_Locations_LocationId", table: "Templates"); migrationBuilder.DropTable( name: "workOrders"); migrationBuilder.DropPrimaryKey( name: "PK_Templates", table: "Templates"); migrationBuilder.RenameTable( name: "Templates", newName: "Template"); migrationBuilder.RenameIndex( name: "IX_Templates_LocationId", table: "Template", newName: "IX_Template_LocationId"); migrationBuilder.RenameIndex( name: "IX_Templates_CategoryId", table: "Template", newName: "IX_Template_CategoryId"); migrationBuilder.RenameIndex( name: "IX_Templates_AssignTo", table: "Template", newName: "IX_Template_AssignTo"); migrationBuilder.AddPrimaryKey( name: "PK_Template", table: "Template", column: "Id"); migrationBuilder.CreateTable( name: "WorkerOrder", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AssignTo = table.Column(type: "nvarchar(450)", nullable: true), CategoryId = table.Column(type: "int", nullable: true), LocationId = table.Column(type: "int", nullable: true), AfterPhotoAttachment = table.Column(type: "nvarchar(max)", nullable: true), AfterPhotoIssue = table.Column(type: "nvarchar(max)", nullable: true), Attachments = table.Column(type: "nvarchar(max)", nullable: true), BeforPhotoAttachment = table.Column(type: "nvarchar(max)", nullable: true), BeforPhotoIssue = table.Column(type: "nvarchar(max)", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: true), DeleterUserId = table.Column(type: "nvarchar(max)", nullable: true), DeletionTime = table.Column(type: "datetime2", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true), DueDate = table.Column(type: "datetime2", nullable: true), IsDeleted = table.Column(type: "bit", nullable: true), LastModificationTime = table.Column(type: "datetime2", nullable: true), LastModifierUserId = table.Column(type: "int", nullable: true), PO = table.Column(type: "nvarchar(max)", nullable: true), POC = table.Column(type: "nvarchar(max)", nullable: true), Priority = table.Column(type: "nvarchar(max)", nullable: true), SignOffName = table.Column(type: "nvarchar(max)", nullable: true), SignOffSignature = table.Column(type: "nvarchar(max)", nullable: true), Status = table.Column(type: "nvarchar(max)", nullable: true), TT = table.Column(type: "nvarchar(max)", nullable: true), WorkerOrderNumber = table.Column(type: "nvarchar(max)", nullable: true), WorkerOrderTitle = table.Column(type: "nvarchar(max)", nullable: true), createdby = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WorkerOrder", x => x.Id); table.ForeignKey( name: "FK_WorkerOrder_AspNetUsers_AssignTo", column: x => x.AssignTo, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_WorkerOrder_Categories_CategoryId", column: x => x.CategoryId, principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_WorkerOrder_Locations_LocationId", column: x => x.LocationId, principalTable: "Locations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_WorkerOrder_AssignTo", table: "WorkerOrder", column: "AssignTo"); migrationBuilder.CreateIndex( name: "IX_WorkerOrder_CategoryId", table: "WorkerOrder", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_WorkerOrder_LocationId", table: "WorkerOrder", column: "LocationId"); migrationBuilder.AddForeignKey( name: "FK_Comments_WorkerOrder_WorkerOrderId", table: "Comments", column: "WorkerOrderId", principalTable: "WorkerOrder", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Template_AspNetUsers_AssignTo", table: "Template", column: "AssignTo", principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Template_Categories_CategoryId", table: "Template", column: "CategoryId", principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Template_Locations_LocationId", table: "Template", column: "LocationId", principalTable: "Locations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } } }