using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddJobTemplates : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "JobTemplates", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), CustomerId = table.Column(type: "int", nullable: true), SpecialInstructions = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), UsageCount = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobTemplateId = table.Column(type: "int", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Quantity = table.Column(type: "decimal(18,2)", nullable: false), SurfaceAreaSqFt = table.Column(type: "decimal(18,2)", nullable: false), CatalogItemId = table.Column(type: "int", nullable: true), IsGenericItem = table.Column(type: "bit", nullable: false), IsLaborItem = table.Column(type: "bit", nullable: false), ManualUnitPrice = table.Column(type: "decimal(18,2)", nullable: true), RequiresSandblasting = table.Column(type: "bit", nullable: false), RequiresMasking = table.Column(type: "bit", nullable: false), IncludePrepCost = table.Column(type: "bit", nullable: false), EstimatedMinutes = table.Column(type: "int", nullable: false), Complexity = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), DisplayOrder = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobTemplateItemId = table.Column(type: "int", nullable: false), CoatName = table.Column(type: "nvarchar(max)", nullable: false), Sequence = table.Column(type: "int", nullable: false), InventoryItemId = table.Column(type: "int", nullable: true), ColorName = table.Column(type: "nvarchar(max)", nullable: true), VendorId = table.Column(type: "int", nullable: true), ColorCode = table.Column(type: "nvarchar(max)", nullable: true), Finish = table.Column(type: "nvarchar(max)", nullable: true), CoverageSqFtPerLb = table.Column(type: "decimal(18,2)", nullable: false), TransferEfficiency = table.Column(type: "decimal(18,2)", nullable: false), PowderCostPerLb = table.Column(type: "decimal(18,2)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobTemplateItemId = table.Column(type: "int", nullable: false), PrepServiceId = table.Column(type: "int", nullable: false), EstimatedMinutes = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(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"); } /// 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)); } } }