using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Data.SeaHavenIndustries.Migrations { /// public partial class Phase6_CompletionSlideOver : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "Category", table: "workOrderAttachments", type: "int", nullable: true); migrationBuilder.CreateTable( name: "CompletionDocTemplates", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), ServiceKey = table.Column(type: "nvarchar(450)", nullable: false), WorkOrderType = table.Column(type: "int", nullable: true), TemplateUrl = table.Column(type: "nvarchar(max)", nullable: false), IsActive = table.Column(type: "bit", nullable: false), 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_CompletionDocTemplates", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_CompletionDocTemplates_ServiceKey_IsActive", table: "CompletionDocTemplates", columns: new[] { "ServiceKey", "IsActive" }); migrationBuilder.Sql(@" UPDATE workOrders SET DocStatus = 1 WHERE DocStatus IS NULL AND SignOffAttachment IS NOT NULL AND LTRIM(RTRIM(SignOffAttachment)) <> ''; "); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.Sql(@" UPDATE workOrders SET DocStatus = NULL WHERE DocStatus = 1 AND SignOffAttachment IS NOT NULL AND LTRIM(RTRIM(SignOffAttachment)) <> ''; "); migrationBuilder.DropTable( name: "CompletionDocTemplates"); migrationBuilder.DropColumn( name: "Category", table: "workOrderAttachments"); } } }