shoc-backend/Data.SeaHavenIndustries/Migrations/20260625120000_Phase6_CompletionSlideOver.cs

77 lines
3.1 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class Phase6_CompletionSlideOver : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Category",
table: "workOrderAttachments",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "CompletionDocTemplates",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
ServiceKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkOrderType = table.Column<int>(type: "int", nullable: true),
TemplateUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(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)) <> '';
");
}
/// <inheritdoc />
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");
}
}
}