Files
PowderCoatingLogix/src/PowderCoating.Infrastructure/Migrations/20260319023827_AddJobTemplates.cs
T
2026-04-23 21:38:24 -04:00

274 lines
14 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJobTemplates : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "JobTemplates",
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),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
CustomerId = table.Column<int>(type: "int", nullable: true),
SpecialInstructions = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
UsageCount = table.Column<int>(type: "int", nullable: false),
CompanyId = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobTemplates", x => x.Id);
table.ForeignKey(
name: "FK_JobTemplates_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "JobTemplateItems",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobTemplateId = table.Column<int>(type: "int", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Quantity = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
SurfaceAreaSqFt = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
CatalogItemId = table.Column<int>(type: "int", nullable: true),
IsGenericItem = table.Column<bool>(type: "bit", nullable: false),
IsLaborItem = table.Column<bool>(type: "bit", nullable: false),
ManualUnitPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
RequiresSandblasting = table.Column<bool>(type: "bit", nullable: false),
RequiresMasking = table.Column<bool>(type: "bit", nullable: false),
IncludePrepCost = table.Column<bool>(type: "bit", nullable: false),
EstimatedMinutes = table.Column<int>(type: "int", nullable: false),
Complexity = table.Column<string>(type: "nvarchar(max)", nullable: true),
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
CompanyId = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobTemplateItems", x => x.Id);
table.ForeignKey(
name: "FK_JobTemplateItems_CatalogItems_CatalogItemId",
column: x => x.CatalogItemId,
principalTable: "CatalogItems",
principalColumn: "Id");
table.ForeignKey(
name: "FK_JobTemplateItems_JobTemplates_JobTemplateId",
column: x => x.JobTemplateId,
principalTable: "JobTemplates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "JobTemplateItemCoats",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobTemplateItemId = table.Column<int>(type: "int", nullable: false),
CoatName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Sequence = table.Column<int>(type: "int", nullable: false),
InventoryItemId = table.Column<int>(type: "int", nullable: true),
ColorName = table.Column<string>(type: "nvarchar(max)", nullable: true),
VendorId = table.Column<int>(type: "int", nullable: true),
ColorCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
Finish = table.Column<string>(type: "nvarchar(max)", nullable: true),
CoverageSqFtPerLb = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
TransferEfficiency = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
PowderCostPerLb = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobTemplateItemCoats", x => x.Id);
table.ForeignKey(
name: "FK_JobTemplateItemCoats_InventoryItems_InventoryItemId",
column: x => x.InventoryItemId,
principalTable: "InventoryItems",
principalColumn: "Id");
table.ForeignKey(
name: "FK_JobTemplateItemCoats_JobTemplateItems_JobTemplateItemId",
column: x => x.JobTemplateItemId,
principalTable: "JobTemplateItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JobTemplateItemCoats_Vendors_VendorId",
column: x => x.VendorId,
principalTable: "Vendors",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "JobTemplateItemPrepServices",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobTemplateItemId = table.Column<int>(type: "int", nullable: false),
PrepServiceId = table.Column<int>(type: "int", nullable: false),
EstimatedMinutes = table.Column<int>(type: "int", nullable: false),
CompanyId = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobTemplateItemPrepServices", x => x.Id);
table.ForeignKey(
name: "FK_JobTemplateItemPrepServices_JobTemplateItems_JobTemplateItemId",
column: x => x.JobTemplateItemId,
principalTable: "JobTemplateItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JobTemplateItemPrepServices_PrepServices_PrepServiceId",
column: x => x.PrepServiceId,
principalTable: "PrepServices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5291));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5296));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 3, 19, 2, 38, 23, 419, DateTimeKind.Utc).AddTicks(5298));
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItemCoats_InventoryItemId",
table: "JobTemplateItemCoats",
column: "InventoryItemId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItemCoats_JobTemplateItemId",
table: "JobTemplateItemCoats",
column: "JobTemplateItemId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItemCoats_VendorId",
table: "JobTemplateItemCoats",
column: "VendorId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItemPrepServices_JobTemplateItemId",
table: "JobTemplateItemPrepServices",
column: "JobTemplateItemId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItemPrepServices_PrepServiceId",
table: "JobTemplateItemPrepServices",
column: "PrepServiceId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItems_CatalogItemId",
table: "JobTemplateItems",
column: "CatalogItemId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplateItems_JobTemplateId",
table: "JobTemplateItems",
column: "JobTemplateId");
migrationBuilder.CreateIndex(
name: "IX_JobTemplates_CustomerId",
table: "JobTemplates",
column: "CustomerId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobTemplateItemCoats");
migrationBuilder.DropTable(
name: "JobTemplateItemPrepServices");
migrationBuilder.DropTable(
name: "JobTemplateItems");
migrationBuilder.DropTable(
name: "JobTemplates");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 3, 18, 22, 26, 44, 934, DateTimeKind.Utc).AddTicks(9567));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 3, 18, 22, 26, 44, 934, DateTimeKind.Utc).AddTicks(9573));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 3, 18, 22, 26, 44, 934, DateTimeKind.Utc).AddTicks(9575));
}
}
}