Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,475 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMultiTenancy : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// STEP 1: Create Companies table FIRST
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CompanyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
CompanyCode = table.Column<string>(type: "nvarchar(450)", nullable: true),
PrimaryContactName = table.Column<string>(type: "nvarchar(max)", nullable: false),
PrimaryContactEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
Address = table.Column<string>(type: "nvarchar(max)", nullable: true),
City = table.Column<string>(type: "nvarchar(max)", nullable: true),
State = table.Column<string>(type: "nvarchar(max)", nullable: true),
ZipCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
SubscriptionStartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
SubscriptionEndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
SubscriptionPlan = table.Column<string>(type: "nvarchar(max)", nullable: true),
TimeZone = table.Column<string>(type: "nvarchar(max)", nullable: true),
LogoPath = table.Column<string>(type: "nvarchar(max)", nullable: true),
Settings = 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_Companies", x => x.Id);
});
// Create unique index on CompanyCode
migrationBuilder.CreateIndex(
name: "IX_Companies_CompanyCode",
table: "Companies",
column: "CompanyCode",
unique: true,
filter: "[CompanyCode] IS NOT NULL");
// STEP 2: Insert default company with Id=1
migrationBuilder.Sql(@"
SET IDENTITY_INSERT Companies ON;
INSERT INTO Companies (Id, CompanyName, CompanyCode, PrimaryContactName, PrimaryContactEmail, Phone, Address, City, State, ZipCode, IsActive, SubscriptionStartDate, SubscriptionPlan, TimeZone, CompanyId, CreatedAt, IsDeleted)
VALUES (1, 'Demo Company', 'DEMO', 'Admin User', 'admin@demo.com', '(555) 123-4567', '123 Demo Street', 'Demo City', 'CA', '90210', 1, GETUTCDATE(), 'Enterprise', 'America/New_York', 1, GETUTCDATE(), 0);
SET IDENTITY_INSERT Companies OFF;
");
// STEP 3: Add CompanyId columns to all tables with DEFAULT 1 (references the company we just created)
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "Suppliers",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "Quotes",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "QuoteItems",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "PricingTiers",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "MaintenanceRecords",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "JobStatusHistory",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "Jobs",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "JobPhotos",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "JobNotes",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "JobItems",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "InventoryTransactions",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "InventoryItems",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "Equipment",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "Customers",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "CustomerNotes",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<int>(
name: "CompanyId",
table: "AspNetUsers",
type: "int",
nullable: false,
defaultValue: 1);
migrationBuilder.AddColumn<string>(
name: "CompanyRole",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
// Update seeded PricingTiers to have CompanyId=1
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "CompanyId", "CreatedAt" },
values: new object[] { 1, new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5235) });
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "CompanyId", "CreatedAt" },
values: new object[] { 1, new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5242) });
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
columns: new[] { "CompanyId", "CreatedAt" },
values: new object[] { 1, new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5243) });
// STEP 4: Create indexes on CompanyId columns
migrationBuilder.CreateIndex(
name: "IX_Suppliers_CompanyId",
table: "Suppliers",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_Quotes_CompanyId",
table: "Quotes",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_PricingTiers_CompanyId",
table: "PricingTiers",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId",
table: "Jobs",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_InventoryItems_CompanyId",
table: "InventoryItems",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_Equipment_CompanyId",
table: "Equipment",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_Customers_CompanyId",
table: "Customers",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUsers_CompanyId",
table: "AspNetUsers",
column: "CompanyId");
// STEP 5: Add foreign keys (now all existing rows have CompanyId=1 which exists)
migrationBuilder.AddForeignKey(
name: "FK_AspNetUsers_Companies_CompanyId",
table: "AspNetUsers",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Customers_Companies_CompanyId",
table: "Customers",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Equipment_Companies_CompanyId",
table: "Equipment",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_InventoryItems_Companies_CompanyId",
table: "InventoryItems",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Jobs_Companies_CompanyId",
table: "Jobs",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PricingTiers_Companies_CompanyId",
table: "PricingTiers",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Quotes_Companies_CompanyId",
table: "Quotes",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Suppliers_Companies_CompanyId",
table: "Suppliers",
column: "CompanyId",
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AspNetUsers_Companies_CompanyId",
table: "AspNetUsers");
migrationBuilder.DropForeignKey(
name: "FK_Customers_Companies_CompanyId",
table: "Customers");
migrationBuilder.DropForeignKey(
name: "FK_Equipment_Companies_CompanyId",
table: "Equipment");
migrationBuilder.DropForeignKey(
name: "FK_InventoryItems_Companies_CompanyId",
table: "InventoryItems");
migrationBuilder.DropForeignKey(
name: "FK_Jobs_Companies_CompanyId",
table: "Jobs");
migrationBuilder.DropForeignKey(
name: "FK_PricingTiers_Companies_CompanyId",
table: "PricingTiers");
migrationBuilder.DropForeignKey(
name: "FK_Quotes_Companies_CompanyId",
table: "Quotes");
migrationBuilder.DropForeignKey(
name: "FK_Suppliers_Companies_CompanyId",
table: "Suppliers");
migrationBuilder.DropTable(
name: "Companies");
migrationBuilder.DropIndex(
name: "IX_Suppliers_CompanyId",
table: "Suppliers");
migrationBuilder.DropIndex(
name: "IX_Quotes_CompanyId",
table: "Quotes");
migrationBuilder.DropIndex(
name: "IX_PricingTiers_CompanyId",
table: "PricingTiers");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_InventoryItems_CompanyId",
table: "InventoryItems");
migrationBuilder.DropIndex(
name: "IX_Equipment_CompanyId",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_Customers_CompanyId",
table: "Customers");
migrationBuilder.DropIndex(
name: "IX_AspNetUsers_CompanyId",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "Suppliers");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "Quotes");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "PricingTiers");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "JobStatusHistory");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "Jobs");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "JobPhotos");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "JobNotes");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "JobItems");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "InventoryTransactions");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "InventoryItems");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "Equipment");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "Customers");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "CustomerNotes");
migrationBuilder.DropColumn(
name: "CompanyId",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CompanyRole",
table: "AspNetUsers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1418));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1424));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1426));
}
}
}
@@ -0,0 +1,79 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class MakeCompanyNameOptional : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CompanyName",
table: "Customers",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1700));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1704));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1706));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CompanyName",
table: "Customers",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5235));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5242));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 1, 20, 42, 501, DateTimeKind.Utc).AddTicks(5243));
}
}
}
@@ -0,0 +1,108 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCompanyOperatingCosts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CompanyOperatingCosts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CompanyId = table.Column<int>(type: "int", nullable: false),
StandardLaborRate = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
OvertimeLaborRate = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
SpecializedLaborRate = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
ElectricityRatePerKwh = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
GasRatePerUnit = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
WaterRatePerUnit = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
OvenOperatingCostPerHour = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
SandblasterCostPerHour = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
CoatingBoothCostPerHour = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
GeneralMarkupPercentage = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
AdminOverheadPercentage = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
FacilityCostPercentage = table.Column<decimal>(type: "decimal(18,2)", 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_CompanyOperatingCosts", x => x.Id);
table.ForeignKey(
name: "FK_CompanyOperatingCosts_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5021));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5026));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5028));
migrationBuilder.CreateIndex(
name: "IX_CompanyOperatingCosts_CompanyId",
table: "CompanyOperatingCosts",
column: "CompanyId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1700));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1704));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 15, 0, 38, 815, DateTimeKind.Utc).AddTicks(1706));
}
}
}
@@ -0,0 +1,100 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class MakeCustomerEmailOptional : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Customers_Email",
table: "Customers");
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Customers",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1715));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1722));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1724));
migrationBuilder.CreateIndex(
name: "IX_Customers_Email",
table: "Customers",
column: "Email",
unique: true,
filter: "[Email] IS NOT NULL");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Customers_Email",
table: "Customers");
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Customers",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5021));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5026));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 17, 43, 30, 41, DateTimeKind.Utc).AddTicks(5028));
migrationBuilder.CreateIndex(
name: "IX_Customers_Email",
table: "Customers",
column: "Email",
unique: true);
}
}
}
@@ -0,0 +1,159 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdateQuoteForProspects : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "CustomerId",
table: "Quotes",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddColumn<string>(
name: "ProspectAddress",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectCity",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectCompanyName",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectContactName",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectEmail",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectPhone",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectState",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProspectZipCode",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4915));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4919));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4921));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProspectAddress",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectCity",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectCompanyName",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectContactName",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectEmail",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectPhone",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectState",
table: "Quotes");
migrationBuilder.DropColumn(
name: "ProspectZipCode",
table: "Quotes");
migrationBuilder.AlterColumn<int>(
name: "CustomerId",
table: "Quotes",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1715));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1722));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 6, 21, 35, 23, 258, DateTimeKind.Utc).AddTicks(1724));
}
}
}
@@ -0,0 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPowderCoatingCostAndTaxToOperatingCosts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "PowderCoatingCostPerSqFt",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "TaxPercent",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7640));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7647));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7649));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PowderCoatingCostPerSqFt",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "TaxPercent",
table: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4915));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4919));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 42, 43, 279, DateTimeKind.Utc).AddTicks(4921));
}
}
}
@@ -0,0 +1,112 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPowderCostFieldsToQuoteItems : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "InventoryItemId",
table: "QuoteItems",
type: "int",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "PowderCostOverride",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "SurfaceAreaSqFt",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8342));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8349));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8351));
migrationBuilder.CreateIndex(
name: "IX_QuoteItems_InventoryItemId",
table: "QuoteItems",
column: "InventoryItemId");
migrationBuilder.AddForeignKey(
name: "FK_QuoteItems_InventoryItems_InventoryItemId",
table: "QuoteItems",
column: "InventoryItemId",
principalTable: "InventoryItems",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_QuoteItems_InventoryItems_InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropIndex(
name: "IX_QuoteItems_InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "PowderCostOverride",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "SurfaceAreaSqFt",
table: "QuoteItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7640));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7647));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 3, 55, 32, 342, DateTimeKind.Utc).AddTicks(7649));
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCoverageSqFtPerLbToInventoryItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "CoverageSqFtPerLb",
table: "InventoryItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3675));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3680));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3682));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CoverageSqFtPerLb",
table: "InventoryItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8342));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8349));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 4, 32, 10, 99, DateTimeKind.Utc).AddTicks(8351));
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTransferEfficiencyToInventoryItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "TransferEfficiency",
table: "InventoryItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5847));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5851));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5853));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TransferEfficiency",
table: "InventoryItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3675));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3680));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 28, 54, 459, DateTimeKind.Utc).AddTicks(3682));
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,163 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddShopWorkers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "AssignedWorkerId",
table: "MaintenanceRecords",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "AssignedWorkerId",
table: "Jobs",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "ShopWorkers",
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),
Role = table.Column<int>(type: "int", nullable: false),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
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_ShopWorkers", x => x.Id);
table.ForeignKey(
name: "FK_ShopWorkers_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5718));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5725));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5728));
migrationBuilder.CreateIndex(
name: "IX_MaintenanceRecords_AssignedWorkerId",
table: "MaintenanceRecords",
column: "AssignedWorkerId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_AssignedWorkerId",
table: "Jobs",
column: "AssignedWorkerId");
migrationBuilder.CreateIndex(
name: "IX_ShopWorkers_CompanyId",
table: "ShopWorkers",
column: "CompanyId");
migrationBuilder.AddForeignKey(
name: "FK_Jobs_ShopWorkers_AssignedWorkerId",
table: "Jobs",
column: "AssignedWorkerId",
principalTable: "ShopWorkers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_MaintenanceRecords_ShopWorkers_AssignedWorkerId",
table: "MaintenanceRecords",
column: "AssignedWorkerId",
principalTable: "ShopWorkers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Jobs_ShopWorkers_AssignedWorkerId",
table: "Jobs");
migrationBuilder.DropForeignKey(
name: "FK_MaintenanceRecords_ShopWorkers_AssignedWorkerId",
table: "MaintenanceRecords");
migrationBuilder.DropTable(
name: "ShopWorkers");
migrationBuilder.DropIndex(
name: "IX_MaintenanceRecords_AssignedWorkerId",
table: "MaintenanceRecords");
migrationBuilder.DropIndex(
name: "IX_Jobs_AssignedWorkerId",
table: "Jobs");
migrationBuilder.DropColumn(
name: "AssignedWorkerId",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "AssignedWorkerId",
table: "Jobs");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5847));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5851));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5853));
}
}
}
@@ -0,0 +1,81 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class StoreLogoInDatabase : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "LogoPath",
table: "Companies",
newName: "LogoContentType");
migrationBuilder.AddColumn<byte[]>(
name: "LogoData",
table: "Companies",
type: "varbinary(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9664));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9711));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9713));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LogoData",
table: "Companies");
migrationBuilder.RenameColumn(
name: "LogoContentType",
table: "Companies",
newName: "LogoPath");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5718));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5725));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5728));
}
}
}
@@ -0,0 +1,91 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddProfilePictureAndSidebarColor : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ProfilePicturePath",
table: "AspNetUsers",
newName: "SidebarColor");
migrationBuilder.AddColumn<string>(
name: "ProfilePictureContentType",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<byte[]>(
name: "ProfilePictureData",
table: "AspNetUsers",
type: "varbinary(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(7992));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(8000));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(8002));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProfilePictureContentType",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "ProfilePictureData",
table: "AspNetUsers");
migrationBuilder.RenameColumn(
name: "SidebarColor",
table: "AspNetUsers",
newName: "ProfilePicturePath");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9664));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9711));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 0, 14, 752, DateTimeKind.Utc).AddTicks(9713));
}
}
}
@@ -0,0 +1,122 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCompanyPreferences : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CompanyPreferences",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CompanyId = table.Column<int>(type: "int", nullable: false),
DefaultCurrency = table.Column<string>(type: "nvarchar(max)", nullable: false),
DefaultDateFormat = table.Column<string>(type: "nvarchar(max)", nullable: false),
DefaultTimeFormat = table.Column<string>(type: "nvarchar(max)", nullable: false),
DefaultPaymentTerms = table.Column<string>(type: "nvarchar(max)", nullable: false),
DefaultQuoteValidityDays = table.Column<int>(type: "int", nullable: false),
QuoteNumberPrefix = table.Column<string>(type: "nvarchar(max)", nullable: false),
JobNumberPrefix = table.Column<string>(type: "nvarchar(max)", nullable: false),
DefaultJobPriority = table.Column<string>(type: "nvarchar(max)", nullable: false),
RequireCustomerPO = table.Column<bool>(type: "bit", nullable: false),
AllowCustomerApproval = table.Column<bool>(type: "bit", nullable: false),
DefaultTurnaroundDays = table.Column<int>(type: "int", nullable: false),
EnableSandblastingStep = table.Column<bool>(type: "bit", nullable: false),
EnableMaskingStep = table.Column<bool>(type: "bit", nullable: false),
EmailNotificationsEnabled = table.Column<bool>(type: "bit", nullable: false),
NotifyOnNewJob = table.Column<bool>(type: "bit", nullable: false),
NotifyOnJobStatusChange = table.Column<bool>(type: "bit", nullable: false),
NotifyOnQuoteApproval = table.Column<bool>(type: "bit", nullable: false),
NotifyOnPaymentReceived = table.Column<bool>(type: "bit", nullable: false),
QuoteExpiryWarningDays = table.Column<int>(type: "int", nullable: false),
DueDateWarningDays = table.Column<int>(type: "int", nullable: false),
MaintenanceAlertDays = table.Column<int>(type: "int", nullable: false),
QuoteRetentionYears = table.Column<int>(type: "int", nullable: false),
JobRetentionYears = table.Column<int>(type: "int", nullable: false),
LogRetentionDays = table.Column<int>(type: "int", nullable: false),
AutoArchiveJobsDays = table.Column<int>(type: "int", nullable: false),
DeletedRecordRetentionDays = 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_CompanyPreferences", x => x.Id);
table.ForeignKey(
name: "FK_CompanyPreferences_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3756));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3760));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3762));
migrationBuilder.CreateIndex(
name: "IX_CompanyPreferences_CompanyId",
table: "CompanyPreferences",
column: "CompanyId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CompanyPreferences");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(7992));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(8000));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 16, 43, 39, 97, DateTimeKind.Utc).AddTicks(8002));
}
}
}
@@ -0,0 +1,102 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTaxExemptionToCustomer : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsTaxExempt",
table: "Customers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "TaxExemptCertificateContentType",
table: "Customers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<byte[]>(
name: "TaxExemptCertificateData",
table: "Customers",
type: "varbinary(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "TaxExemptCertificateFileName",
table: "Customers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2986));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2993));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2995));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsTaxExempt",
table: "Customers");
migrationBuilder.DropColumn(
name: "TaxExemptCertificateContentType",
table: "Customers");
migrationBuilder.DropColumn(
name: "TaxExemptCertificateData",
table: "Customers");
migrationBuilder.DropColumn(
name: "TaxExemptCertificateFileName",
table: "Customers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3756));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3760));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 18, 14, 35, 849, DateTimeKind.Utc).AddTicks(3762));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddRushChargePercentage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "RushChargePercentage",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(3994));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(3999));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(4001));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RushChargePercentage",
table: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2986));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2993));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 22, 44, 23, 99, DateTimeKind.Utc).AddTicks(2995));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddShopMinimumCharge : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "ShopMinimumCharge",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5506));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5510));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5512));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ShopMinimumCharge",
table: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(3994));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(3999));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 3, 20, 973, DateTimeKind.Utc).AddTicks(4001));
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddProfilePictureFilePath : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ProfilePictureFilePath",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5461));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5466));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5469));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ProfilePictureFilePath",
table: "AspNetUsers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5506));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5510));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 8, 23, 14, 5, 637, DateTimeKind.Utc).AddTicks(5512));
}
}
}
@@ -0,0 +1,162 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdateJobPhotoEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "PhotoDate",
table: "JobPhotos",
newName: "UploadedDate");
migrationBuilder.RenameColumn(
name: "Description",
table: "JobPhotos",
newName: "Caption");
migrationBuilder.AlterColumn<int>(
name: "PhotoType",
table: "JobPhotos",
type: "int",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddColumn<string>(
name: "ContentType",
table: "JobPhotos",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "DisplayOrder",
table: "JobPhotos",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<long>(
name: "FileSize",
table: "JobPhotos",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<string>(
name: "UploadedById",
table: "JobPhotos",
type: "nvarchar(450)",
nullable: false,
defaultValue: "");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9259));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9263));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9265));
migrationBuilder.CreateIndex(
name: "IX_JobPhotos_UploadedById",
table: "JobPhotos",
column: "UploadedById");
migrationBuilder.AddForeignKey(
name: "FK_JobPhotos_AspNetUsers_UploadedById",
table: "JobPhotos",
column: "UploadedById",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_JobPhotos_AspNetUsers_UploadedById",
table: "JobPhotos");
migrationBuilder.DropIndex(
name: "IX_JobPhotos_UploadedById",
table: "JobPhotos");
migrationBuilder.DropColumn(
name: "ContentType",
table: "JobPhotos");
migrationBuilder.DropColumn(
name: "DisplayOrder",
table: "JobPhotos");
migrationBuilder.DropColumn(
name: "FileSize",
table: "JobPhotos");
migrationBuilder.DropColumn(
name: "UploadedById",
table: "JobPhotos");
migrationBuilder.RenameColumn(
name: "UploadedDate",
table: "JobPhotos",
newName: "PhotoDate");
migrationBuilder.RenameColumn(
name: "Caption",
table: "JobPhotos",
newName: "Description");
migrationBuilder.AlterColumn<string>(
name: "PhotoType",
table: "JobPhotos",
type: "nvarchar(max)",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5461));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5466));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 28, 19, 897, DateTimeKind.Utc).AddTicks(5469));
}
}
}
@@ -0,0 +1,121 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddFileSystemStorageForLogosAndManuals : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ManualContentType",
table: "Equipment",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ManualFileName",
table: "Equipment",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ManualFilePath",
table: "Equipment",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<long>(
name: "ManualFileSize",
table: "Equipment",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "ManualUploadedDate",
table: "Equipment",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LogoFilePath",
table: "Companies",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9041));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9046));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9048));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ManualContentType",
table: "Equipment");
migrationBuilder.DropColumn(
name: "ManualFileName",
table: "Equipment");
migrationBuilder.DropColumn(
name: "ManualFilePath",
table: "Equipment");
migrationBuilder.DropColumn(
name: "ManualFileSize",
table: "Equipment");
migrationBuilder.DropColumn(
name: "ManualUploadedDate",
table: "Equipment");
migrationBuilder.DropColumn(
name: "LogoFilePath",
table: "Companies");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9259));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9263));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 0, 54, 54, 262, DateTimeKind.Utc).AddTicks(9265));
}
}
}
@@ -0,0 +1,166 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddProductCatalog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CatalogCategories",
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),
ParentCategoryId = table.Column<int>(type: "int", nullable: true),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "bit", 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_CatalogCategories", x => x.Id);
table.ForeignKey(
name: "FK_CatalogCategories_CatalogCategories_ParentCategoryId",
column: x => x.ParentCategoryId,
principalTable: "CatalogCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CatalogCategories_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CatalogItems",
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),
SKU = table.Column<string>(type: "nvarchar(max)", nullable: true),
CategoryId = table.Column<int>(type: "int", nullable: false),
DefaultPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
DefaultRequiresSandblasting = table.Column<bool>(type: "bit", nullable: false),
DefaultRequiresMasking = table.Column<bool>(type: "bit", nullable: false),
DefaultEstimatedMinutes = table.Column<int>(type: "int", nullable: true),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "bit", 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_CatalogItems", x => x.Id);
table.ForeignKey(
name: "FK_CatalogItems_CatalogCategories_CategoryId",
column: x => x.CategoryId,
principalTable: "CatalogCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CatalogItems_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 47, 52, 815, DateTimeKind.Utc).AddTicks(5540));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 47, 52, 815, DateTimeKind.Utc).AddTicks(5546));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 47, 52, 815, DateTimeKind.Utc).AddTicks(5548));
migrationBuilder.CreateIndex(
name: "IX_CatalogCategories_CompanyId",
table: "CatalogCategories",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_CatalogCategories_ParentCategoryId",
table: "CatalogCategories",
column: "ParentCategoryId");
migrationBuilder.CreateIndex(
name: "IX_CatalogItems_CategoryId",
table: "CatalogItems",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_CatalogItems_CompanyId",
table: "CatalogItems",
column: "CompanyId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CatalogItems");
migrationBuilder.DropTable(
name: "CatalogCategories");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9041));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9046));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 2, 6, 13, 983, DateTimeKind.Utc).AddTicks(9048));
}
}
}
@@ -0,0 +1,91 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddCatalogItemIdToQuoteItems : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "CatalogItemId",
table: "QuoteItems",
type: "int",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2142));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2149));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2151));
migrationBuilder.CreateIndex(
name: "IX_QuoteItems_CatalogItemId",
table: "QuoteItems",
column: "CatalogItemId");
migrationBuilder.AddForeignKey(
name: "FK_QuoteItems_CatalogItems_CatalogItemId",
table: "QuoteItems",
column: "CatalogItemId",
principalTable: "CatalogItems",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_QuoteItems_CatalogItems_CatalogItemId",
table: "QuoteItems");
migrationBuilder.DropIndex(
name: "IX_QuoteItems_CatalogItemId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "CatalogItemId",
table: "QuoteItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 3, 13, 17, 113, DateTimeKind.Utc).AddTicks(7088));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 3, 13, 17, 113, DateTimeKind.Utc).AddTicks(7093));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 3, 13, 17, 113, DateTimeKind.Utc).AddTicks(7095));
}
}
}
@@ -0,0 +1,149 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdateOperatingCostsRushCharge : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AdminOverheadPercentage",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "ElectricityRatePerKwh",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "FacilityCostPercentage",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "GasRatePerUnit",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "OvertimeLaborRate",
table: "CompanyOperatingCosts");
migrationBuilder.DropColumn(
name: "SpecializedLaborRate",
table: "CompanyOperatingCosts");
migrationBuilder.RenameColumn(
name: "WaterRatePerUnit",
table: "CompanyOperatingCosts",
newName: "RushChargeFixedAmount");
migrationBuilder.AddColumn<string>(
name: "RushChargeType",
table: "CompanyOperatingCosts",
type: "nvarchar(20)",
maxLength: 20,
nullable: false,
defaultValue: "Percentage");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7507));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7511));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7513));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RushChargeType",
table: "CompanyOperatingCosts");
migrationBuilder.RenameColumn(
name: "RushChargeFixedAmount",
table: "CompanyOperatingCosts",
newName: "WaterRatePerUnit");
migrationBuilder.AddColumn<decimal>(
name: "AdminOverheadPercentage",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "ElectricityRatePerKwh",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "FacilityCostPercentage",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "GasRatePerUnit",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "OvertimeLaborRate",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<decimal>(
name: "SpecializedLaborRate",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2142));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2149));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 4, 38, 17, 166, DateTimeKind.Utc).AddTicks(2151));
}
}
}
@@ -0,0 +1,289 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class RemoveUnusedFields : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Jobs_AspNetUsers_AssignedEmployeeId",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Jobs_AssignedEmployeeId",
table: "Jobs");
migrationBuilder.DropColumn(
name: "AIPriceRationale",
table: "Quotes");
migrationBuilder.DropColumn(
name: "AISuggestedPrice",
table: "Quotes");
migrationBuilder.DropColumn(
name: "UsedAISuggestion",
table: "Quotes");
migrationBuilder.DropColumn(
name: "Height",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "Length",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "MeasurementUnit",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "Width",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "ActualCost",
table: "Jobs");
migrationBuilder.DropColumn(
name: "ActualHours",
table: "Jobs");
migrationBuilder.DropColumn(
name: "AssignedEmployeeId",
table: "Jobs");
migrationBuilder.DropColumn(
name: "CustomerApprovedDate",
table: "Jobs");
migrationBuilder.DropColumn(
name: "EstimatedCost",
table: "Jobs");
migrationBuilder.DropColumn(
name: "EstimatedHours",
table: "Jobs");
migrationBuilder.DropColumn(
name: "ActualMinutes",
table: "JobItems");
migrationBuilder.DropColumn(
name: "Height",
table: "JobItems");
migrationBuilder.DropColumn(
name: "Length",
table: "JobItems");
migrationBuilder.DropColumn(
name: "MaterialCost",
table: "JobItems");
migrationBuilder.DropColumn(
name: "MeasurementUnit",
table: "JobItems");
migrationBuilder.DropColumn(
name: "Weight",
table: "JobItems");
migrationBuilder.DropColumn(
name: "Width",
table: "JobItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7815));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7821));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7822));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AIPriceRationale",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "AISuggestedPrice",
table: "Quotes",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "UsedAISuggestion",
table: "Quotes",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<decimal>(
name: "Height",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Length",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "MeasurementUnit",
table: "QuoteItems",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Width",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "ActualCost",
table: "Jobs",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<int>(
name: "ActualHours",
table: "Jobs",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "AssignedEmployeeId",
table: "Jobs",
type: "nvarchar(450)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CustomerApprovedDate",
table: "Jobs",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "EstimatedCost",
table: "Jobs",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<int>(
name: "EstimatedHours",
table: "Jobs",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "ActualMinutes",
table: "JobItems",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<decimal>(
name: "Height",
table: "JobItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Length",
table: "JobItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "MaterialCost",
table: "JobItems",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<string>(
name: "MeasurementUnit",
table: "JobItems",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Weight",
table: "JobItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "Width",
table: "JobItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7507));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7511));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 11, 19, 55, 20, 89, DateTimeKind.Utc).AddTicks(7513));
migrationBuilder.CreateIndex(
name: "IX_Jobs_AssignedEmployeeId",
table: "Jobs",
column: "AssignedEmployeeId");
migrationBuilder.AddForeignKey(
name: "FK_Jobs_AspNetUsers_AssignedEmployeeId",
table: "Jobs",
column: "AssignedEmployeeId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
}
}
@@ -0,0 +1,112 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddSupplierEnhancements : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AccountNumber",
table: "Suppliers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "CreditLimit",
table: "Suppliers",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsPreferred",
table: "Suppliers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "PaymentTerms",
table: "Suppliers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "TaxId",
table: "Suppliers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5660));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5668));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5669));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AccountNumber",
table: "Suppliers");
migrationBuilder.DropColumn(
name: "CreditLimit",
table: "Suppliers");
migrationBuilder.DropColumn(
name: "IsPreferred",
table: "Suppliers");
migrationBuilder.DropColumn(
name: "PaymentTerms",
table: "Suppliers");
migrationBuilder.DropColumn(
name: "TaxId",
table: "Suppliers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7815));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7821));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 13, 50, 54, 482, DateTimeKind.Utc).AddTicks(7822));
}
}
}
@@ -0,0 +1,656 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ConvertEnumsToLookupTables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// ============================================================================
// STEP 1: Add temporary columns to preserve enum values
// ============================================================================
migrationBuilder.AddColumn<int>(
name: "OldStatus",
table: "Jobs",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OldPriority",
table: "Jobs",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OldStatus",
table: "Quotes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OldFromStatus",
table: "JobStatusHistory",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "OldToStatus",
table: "JobStatusHistory",
type: "int",
nullable: false,
defaultValue: 0);
// Copy existing enum values to temp columns
migrationBuilder.Sql("UPDATE Jobs SET OldStatus = Status, OldPriority = Priority");
migrationBuilder.Sql("UPDATE Quotes SET OldStatus = Status");
migrationBuilder.Sql("UPDATE JobStatusHistory SET OldFromStatus = FromStatus, OldToStatus = ToStatus");
// ============================================================================
// STEP 2: Create lookup tables
// ============================================================================
migrationBuilder.CreateTable(
name: "JobStatusLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StatusCode = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "nvarchar(max)", nullable: false),
IconClass = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", nullable: false),
IsTerminalStatus = table.Column<bool>(type: "bit", nullable: false),
IsWorkInProgressStatus = table.Column<bool>(type: "bit", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkflowCategory = 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_JobStatusLookups", x => x.Id);
table.ForeignKey(
name: "FK_JobStatusLookups_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "JobPriorityLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PriorityCode = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "nvarchar(max)", nullable: false),
IconClass = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", nullable: false),
Description = 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_JobPriorityLookups", x => x.Id);
table.ForeignKey(
name: "FK_JobPriorityLookups_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "QuoteStatusLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StatusCode = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "nvarchar(max)", nullable: false),
IconClass = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", nullable: false),
IsApprovedStatus = table.Column<bool>(type: "bit", nullable: false),
IsConvertedStatus = table.Column<bool>(type: "bit", nullable: false),
IsDraftStatus = table.Column<bool>(type: "bit", nullable: false),
Description = 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_QuoteStatusLookups", x => x.Id);
table.ForeignKey(
name: "FK_QuoteStatusLookups_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
// ============================================================================
// STEP 3: Seed lookup data for ALL existing companies
// ============================================================================
// Insert Job Status Lookups (16 statuses per company)
migrationBuilder.Sql(@"
INSERT INTO JobStatusLookups (StatusCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, IsTerminalStatus, IsWorkInProgressStatus, Description, WorkflowCategory, CompanyId, CreatedAt, IsDeleted)
SELECT
s.StatusCode, s.DisplayName, s.DisplayOrder, s.ColorClass, s.IconClass, s.IsActive, s.IsSystemDefined, s.IsTerminalStatus, s.IsWorkInProgressStatus, s.Description, s.WorkflowCategory, c.Id, GETUTCDATE(), 0
FROM Companies c
CROSS JOIN (VALUES
('PENDING', 'Pending', 1, 'secondary', 'bi-clock', 1, 1, 0, 0, 'Job is pending approval or scheduling', 'Pre-Production'),
('QUOTED', 'Quoted', 2, 'info', 'bi-file-earmark-text', 1, 0, 0, 0, 'Quote has been generated', 'Pre-Production'),
('APPROVED', 'Approved', 3, 'primary', 'bi-check-circle', 1, 0, 0, 0, 'Job has been approved', 'Pre-Production'),
('IN_PREPARATION', 'In Preparation', 4, 'warning', 'bi-tools', 1, 0, 0, 1, 'Job is being prepared', 'Production'),
('SANDBLASTING', 'Sandblasting', 5, 'warning', 'bi-hurricane', 1, 0, 0, 1, 'Surface preparation in progress', 'Production'),
('MASKING_TAPING', 'Masking/Taping', 6, 'warning', 'bi-scissors', 1, 0, 0, 1, 'Masking areas for coating', 'Production'),
('CLEANING', 'Cleaning', 7, 'warning', 'bi-droplet', 1, 0, 0, 1, 'Pre-coat cleaning', 'Production'),
('IN_OVEN', 'In Oven', 8, 'warning', 'bi-thermometer-half', 1, 0, 0, 1, 'Pre-heating in oven', 'Production'),
('COATING', 'Coating', 9, 'warning', 'bi-paint-bucket', 1, 0, 0, 1, 'Applying powder coating', 'Production'),
('CURING', 'Curing', 10, 'warning', 'bi-thermometer-sun', 1, 0, 0, 1, 'Heat curing the coating', 'Production'),
('QUALITY_CHECK', 'Quality Check', 11, 'info', 'bi-search', 1, 0, 0, 1, 'Quality inspection', 'Production'),
('COMPLETED', 'Completed', 12, 'success', 'bi-check-all', 1, 1, 1, 0, 'Job is completed', 'Post-Production'),
('READY_FOR_PICKUP', 'Ready for Pickup', 13, 'success', 'bi-box-seam', 1, 0, 0, 0, 'Ready for customer pickup', 'Post-Production'),
('DELIVERED', 'Delivered', 14, 'success', 'bi-truck', 1, 0, 1, 0, 'Delivered to customer', 'Post-Production'),
('ON_HOLD', 'On Hold', 15, 'dark', 'bi-pause-circle', 1, 0, 0, 0, 'Job is temporarily on hold', 'Other'),
('CANCELLED', 'Cancelled', 16, 'danger', 'bi-x-circle', 1, 1, 1, 0, 'Job has been cancelled', 'Other')
) AS s(StatusCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, IsTerminalStatus, IsWorkInProgressStatus, Description, WorkflowCategory)
WHERE c.IsDeleted = 0
");
// Insert Job Priority Lookups (5 priorities per company)
migrationBuilder.Sql(@"
INSERT INTO JobPriorityLookups (PriorityCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, Description, CompanyId, CreatedAt, IsDeleted)
SELECT
p.PriorityCode, p.DisplayName, p.DisplayOrder, p.ColorClass, p.IconClass, p.IsActive, p.IsSystemDefined, p.Description, c.Id, GETUTCDATE(), 0
FROM Companies c
CROSS JOIN (VALUES
('LOW', 'Low', 1, 'secondary', 'bi-arrow-down', 1, 0, 'Low priority job'),
('NORMAL', 'Normal', 2, 'primary', NULL, 1, 1, 'Standard priority job'),
('HIGH', 'High', 3, 'info', 'bi-arrow-up', 1, 0, 'High priority job'),
('URGENT', 'Urgent', 4, 'warning', 'bi-exclamation-triangle', 1, 0, 'Urgent job - expedited processing'),
('RUSH', 'Rush', 5, 'danger', 'bi-lightning', 1, 0, 'Rush job - immediate processing required')
) AS p(PriorityCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, Description)
WHERE c.IsDeleted = 0
");
// Insert Quote Status Lookups (7 statuses per company)
migrationBuilder.Sql(@"
INSERT INTO QuoteStatusLookups (StatusCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, IsApprovedStatus, IsConvertedStatus, IsDraftStatus, Description, CompanyId, CreatedAt, IsDeleted)
SELECT
qs.StatusCode, qs.DisplayName, qs.DisplayOrder, qs.ColorClass, qs.IconClass, qs.IsActive, qs.IsSystemDefined, qs.IsApprovedStatus, qs.IsConvertedStatus, qs.IsDraftStatus, qs.Description, c.Id, GETUTCDATE(), 0
FROM Companies c
CROSS JOIN (VALUES
('DRAFT', 'Draft', 1, 'secondary', 'bi-pencil', 1, 1, 0, 0, 1, 'Quote is being drafted'),
('SENT', 'Sent', 2, 'info', 'bi-send', 1, 0, 0, 0, 0, 'Quote has been sent to customer'),
('APPROVED', 'Approved', 3, 'success', 'bi-check-circle', 1, 1, 1, 0, 0, 'Quote has been approved by customer'),
('REJECTED', 'Rejected', 4, 'danger', 'bi-x-circle', 1, 0, 0, 0, 0, 'Quote was rejected by customer'),
('EXPIRED', 'Expired', 5, 'dark', 'bi-clock-history', 1, 0, 0, 0, 0, 'Quote has expired'),
('CONVERTED', 'Converted', 6, 'primary', 'bi-arrow-right-circle', 1, 1, 0, 1, 0, 'Quote has been converted to job'),
('REVISED', 'Revised', 7, 'warning', 'bi-arrow-clockwise', 1, 0, 0, 0, 0, 'Quote is being revised')
) AS qs(StatusCode, DisplayName, DisplayOrder, ColorClass, IconClass, IsActive, IsSystemDefined, IsApprovedStatus, IsConvertedStatus, IsDraftStatus, Description)
WHERE c.IsDeleted = 0
");
// ============================================================================
// STEP 4: Rename and add new FK columns
// ============================================================================
migrationBuilder.RenameColumn(
name: "Status",
table: "Jobs",
newName: "JobStatusId_OLD");
migrationBuilder.RenameColumn(
name: "Priority",
table: "Jobs",
newName: "JobPriorityId_OLD");
migrationBuilder.RenameColumn(
name: "Status",
table: "Quotes",
newName: "QuoteStatusId_OLD");
migrationBuilder.RenameColumn(
name: "FromStatus",
table: "JobStatusHistory",
newName: "FromStatusId_OLD");
migrationBuilder.RenameColumn(
name: "ToStatus",
table: "JobStatusHistory",
newName: "ToStatusId_OLD");
// Add new FK columns (nullable initially)
migrationBuilder.AddColumn<int>(
name: "JobStatusId",
table: "Jobs",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "JobPriorityId",
table: "Jobs",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "QuoteStatusId",
table: "Quotes",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "FromStatusId",
table: "JobStatusHistory",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ToStatusId",
table: "JobStatusHistory",
type: "int",
nullable: true);
// ============================================================================
// STEP 5: Map enum values to lookup IDs
// ============================================================================
// Map Job Status: enum int (0-15) -> lookup ID
// Enum: Pending=0, Quoted=1, Approved=2, InPreparation=3, Sandblasting=4, MaskingTaping=5,
// Cleaning=6, InOven=7, Coating=8, Curing=9, QualityCheck=10, Completed=11,
// ReadyForPickup=12, Delivered=13, OnHold=14, Cancelled=15
migrationBuilder.Sql(@"
UPDATE j
SET j.JobStatusId = s.Id
FROM Jobs j
INNER JOIN JobStatusLookups s ON j.CompanyId = s.CompanyId
WHERE s.StatusCode = CASE j.OldStatus
WHEN 0 THEN 'PENDING'
WHEN 1 THEN 'QUOTED'
WHEN 2 THEN 'APPROVED'
WHEN 3 THEN 'IN_PREPARATION'
WHEN 4 THEN 'SANDBLASTING'
WHEN 5 THEN 'MASKING_TAPING'
WHEN 6 THEN 'CLEANING'
WHEN 7 THEN 'IN_OVEN'
WHEN 8 THEN 'COATING'
WHEN 9 THEN 'CURING'
WHEN 10 THEN 'QUALITY_CHECK'
WHEN 11 THEN 'COMPLETED'
WHEN 12 THEN 'READY_FOR_PICKUP'
WHEN 13 THEN 'DELIVERED'
WHEN 14 THEN 'ON_HOLD'
WHEN 15 THEN 'CANCELLED'
END
");
// Map Job Priority: enum int (0-4) -> lookup ID
// Enum: Low=0, Normal=1, High=2, Urgent=3, Rush=4
migrationBuilder.Sql(@"
UPDATE j
SET j.JobPriorityId = p.Id
FROM Jobs j
INNER JOIN JobPriorityLookups p ON j.CompanyId = p.CompanyId
WHERE p.PriorityCode = CASE j.OldPriority
WHEN 0 THEN 'LOW'
WHEN 1 THEN 'NORMAL'
WHEN 2 THEN 'HIGH'
WHEN 3 THEN 'URGENT'
WHEN 4 THEN 'RUSH'
END
");
// Map Quote Status: enum int (0-6) -> lookup ID
// Enum: Draft=0, Sent=1, Approved=2, Rejected=3, Expired=4, Converted=5, Revised=6
migrationBuilder.Sql(@"
UPDATE q
SET q.QuoteStatusId = s.Id
FROM Quotes q
INNER JOIN QuoteStatusLookups s ON q.CompanyId = s.CompanyId
WHERE s.StatusCode = CASE q.OldStatus
WHEN 0 THEN 'DRAFT'
WHEN 1 THEN 'SENT'
WHEN 2 THEN 'APPROVED'
WHEN 3 THEN 'REJECTED'
WHEN 4 THEN 'EXPIRED'
WHEN 5 THEN 'CONVERTED'
WHEN 6 THEN 'REVISED'
END
");
// Map JobStatusHistory FromStatus and ToStatus
migrationBuilder.Sql(@"
UPDATE h
SET h.FromStatusId = s.Id
FROM JobStatusHistory h
INNER JOIN Jobs j ON h.JobId = j.Id
INNER JOIN JobStatusLookups s ON j.CompanyId = s.CompanyId
WHERE s.StatusCode = CASE h.OldFromStatus
WHEN 0 THEN 'PENDING'
WHEN 1 THEN 'QUOTED'
WHEN 2 THEN 'APPROVED'
WHEN 3 THEN 'IN_PREPARATION'
WHEN 4 THEN 'SANDBLASTING'
WHEN 5 THEN 'MASKING_TAPING'
WHEN 6 THEN 'CLEANING'
WHEN 7 THEN 'IN_OVEN'
WHEN 8 THEN 'COATING'
WHEN 9 THEN 'CURING'
WHEN 10 THEN 'QUALITY_CHECK'
WHEN 11 THEN 'COMPLETED'
WHEN 12 THEN 'READY_FOR_PICKUP'
WHEN 13 THEN 'DELIVERED'
WHEN 14 THEN 'ON_HOLD'
WHEN 15 THEN 'CANCELLED'
END
");
migrationBuilder.Sql(@"
UPDATE h
SET h.ToStatusId = s.Id
FROM JobStatusHistory h
INNER JOIN Jobs j ON h.JobId = j.Id
INNER JOIN JobStatusLookups s ON j.CompanyId = s.CompanyId
WHERE s.StatusCode = CASE h.OldToStatus
WHEN 0 THEN 'PENDING'
WHEN 1 THEN 'QUOTED'
WHEN 2 THEN 'APPROVED'
WHEN 3 THEN 'IN_PREPARATION'
WHEN 4 THEN 'SANDBLASTING'
WHEN 5 THEN 'MASKING_TAPING'
WHEN 6 THEN 'CLEANING'
WHEN 7 THEN 'IN_OVEN'
WHEN 8 THEN 'COATING'
WHEN 9 THEN 'CURING'
WHEN 10 THEN 'QUALITY_CHECK'
WHEN 11 THEN 'COMPLETED'
WHEN 12 THEN 'READY_FOR_PICKUP'
WHEN 13 THEN 'DELIVERED'
WHEN 14 THEN 'ON_HOLD'
WHEN 15 THEN 'CANCELLED'
END
");
// ============================================================================
// STEP 6: Make FK columns NOT NULL
// ============================================================================
migrationBuilder.AlterColumn<int>(
name: "JobStatusId",
table: "Jobs",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "JobPriorityId",
table: "Jobs",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "QuoteStatusId",
table: "Quotes",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "FromStatusId",
table: "JobStatusHistory",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ToStatusId",
table: "JobStatusHistory",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
// ============================================================================
// STEP 7: Create indexes and foreign keys
// ============================================================================
migrationBuilder.CreateIndex(
name: "IX_Jobs_JobStatusId",
table: "Jobs",
column: "JobStatusId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_JobPriorityId",
table: "Jobs",
column: "JobPriorityId");
migrationBuilder.CreateIndex(
name: "IX_Quotes_QuoteStatusId",
table: "Quotes",
column: "QuoteStatusId");
migrationBuilder.CreateIndex(
name: "IX_JobStatusHistory_FromStatusId",
table: "JobStatusHistory",
column: "FromStatusId");
migrationBuilder.CreateIndex(
name: "IX_JobStatusHistory_ToStatusId",
table: "JobStatusHistory",
column: "ToStatusId");
migrationBuilder.CreateIndex(
name: "IX_JobStatusLookups_CompanyId",
table: "JobStatusLookups",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_JobStatusLookups_CompanyId_StatusCode",
table: "JobStatusLookups",
columns: new[] { "CompanyId", "StatusCode" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_JobPriorityLookups_CompanyId",
table: "JobPriorityLookups",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_JobPriorityLookups_CompanyId_PriorityCode",
table: "JobPriorityLookups",
columns: new[] { "CompanyId", "PriorityCode" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_QuoteStatusLookups_CompanyId",
table: "QuoteStatusLookups",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_QuoteStatusLookups_CompanyId_StatusCode",
table: "QuoteStatusLookups",
columns: new[] { "CompanyId", "StatusCode" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Jobs_JobStatusLookups_JobStatusId",
table: "Jobs",
column: "JobStatusId",
principalTable: "JobStatusLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Jobs_JobPriorityLookups_JobPriorityId",
table: "Jobs",
column: "JobPriorityId",
principalTable: "JobPriorityLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Quotes_QuoteStatusLookups_QuoteStatusId",
table: "Quotes",
column: "QuoteStatusId",
principalTable: "QuoteStatusLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_JobStatusHistory_JobStatusLookups_FromStatusId",
table: "JobStatusHistory",
column: "FromStatusId",
principalTable: "JobStatusLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_JobStatusHistory_JobStatusLookups_ToStatusId",
table: "JobStatusHistory",
column: "ToStatusId",
principalTable: "JobStatusLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
// ============================================================================
// STEP 8: Drop old columns and temp columns
// ============================================================================
migrationBuilder.DropColumn(name: "OldStatus", table: "Jobs");
migrationBuilder.DropColumn(name: "OldPriority", table: "Jobs");
migrationBuilder.DropColumn(name: "OldStatus", table: "Quotes");
migrationBuilder.DropColumn(name: "OldFromStatus", table: "JobStatusHistory");
migrationBuilder.DropColumn(name: "OldToStatus", table: "JobStatusHistory");
migrationBuilder.DropColumn(name: "JobStatusId_OLD", table: "Jobs");
migrationBuilder.DropColumn(name: "JobPriorityId_OLD", table: "Jobs");
migrationBuilder.DropColumn(name: "QuoteStatusId_OLD", table: "Quotes");
migrationBuilder.DropColumn(name: "FromStatusId_OLD", table: "JobStatusHistory");
migrationBuilder.DropColumn(name: "ToStatusId_OLD", table: "JobStatusHistory");
// Update PricingTiers seed data timestamps
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1116));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1124));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1127));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
// Drop foreign keys
migrationBuilder.DropForeignKey(name: "FK_Jobs_JobStatusLookups_JobStatusId", table: "Jobs");
migrationBuilder.DropForeignKey(name: "FK_Jobs_JobPriorityLookups_JobPriorityId", table: "Jobs");
migrationBuilder.DropForeignKey(name: "FK_Quotes_QuoteStatusLookups_QuoteStatusId", table: "Quotes");
migrationBuilder.DropForeignKey(name: "FK_JobStatusHistory_JobStatusLookups_FromStatusId", table: "JobStatusHistory");
migrationBuilder.DropForeignKey(name: "FK_JobStatusHistory_JobStatusLookups_ToStatusId", table: "JobStatusHistory");
// Drop indexes
migrationBuilder.DropIndex(name: "IX_Jobs_JobStatusId", table: "Jobs");
migrationBuilder.DropIndex(name: "IX_Jobs_JobPriorityId", table: "Jobs");
migrationBuilder.DropIndex(name: "IX_Quotes_QuoteStatusId", table: "Quotes");
migrationBuilder.DropIndex(name: "IX_JobStatusHistory_FromStatusId", table: "JobStatusHistory");
migrationBuilder.DropIndex(name: "IX_JobStatusHistory_ToStatusId", table: "JobStatusHistory");
// Drop lookup tables
migrationBuilder.DropTable(name: "JobStatusLookups");
migrationBuilder.DropTable(name: "JobPriorityLookups");
migrationBuilder.DropTable(name: "QuoteStatusLookups");
// Rename columns back to enum names
migrationBuilder.RenameColumn(name: "JobStatusId", table: "Jobs", newName: "Status");
migrationBuilder.RenameColumn(name: "JobPriorityId", table: "Jobs", newName: "Priority");
migrationBuilder.RenameColumn(name: "QuoteStatusId", table: "Quotes", newName: "Status");
migrationBuilder.RenameColumn(name: "FromStatusId", table: "JobStatusHistory", newName: "FromStatus");
migrationBuilder.RenameColumn(name: "ToStatusId", table: "JobStatusHistory", newName: "ToStatus");
// Update PricingTiers timestamps
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5660));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5668));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 16, 25, 10, 85, DateTimeKind.Utc).AddTicks(5669));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddShopSuppliesRateToOperatingCosts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "ShopSuppliesRate",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6427));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6433));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6437));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ShopSuppliesRate",
table: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1116));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1124));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 13, 18, 39, 9, 909, DateTimeKind.Utc).AddTicks(1127));
}
}
}
@@ -0,0 +1,177 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddInventoryCategoryLookup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "InventoryCategoryId",
table: "InventoryItems",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "InventoryCategoryLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CategoryCode = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", 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_InventoryCategoryLookups", x => x.Id);
table.ForeignKey(
name: "FK_InventoryCategoryLookups_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1520));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1525));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1527));
// Seed inventory categories for all existing companies
migrationBuilder.Sql(@"
INSERT INTO InventoryCategoryLookups (CategoryCode, DisplayName, DisplayOrder, IsActive, IsSystemDefined, CompanyId, CreatedAt, IsDeleted)
SELECT 'POWDER', 'Powder', 1, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'PRIMER', 'Primer', 2, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'CLEANER', 'Cleaner', 3, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'MASKING', 'Masking Supplies', 4, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'ABRASIVE', 'Abrasive Media', 5, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'CHEMICAL', 'Chemicals', 6, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'CONSUMABLE', 'Consumables', 7, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'TOOL', 'Tools', 8, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
UNION ALL
SELECT 'OTHER', 'Other', 9, 1, 1, c.Id, GETUTCDATE(), 0 FROM Companies c
");
// Map existing inventory items to the new lookup table based on their Category string value
migrationBuilder.Sql(@"
UPDATE i
SET i.InventoryCategoryId = c.Id
FROM InventoryItems i
INNER JOIN InventoryCategoryLookups c ON i.CompanyId = c.CompanyId
WHERE i.Category = 'Powder' AND c.CategoryCode = 'POWDER'
OR i.Category = 'Primer' AND c.CategoryCode = 'PRIMER'
OR i.Category = 'Cleaner' AND c.CategoryCode = 'CLEANER'
OR i.Category = 'Masking' AND c.CategoryCode = 'MASKING'
OR i.Category = 'Abrasive' AND c.CategoryCode = 'ABRASIVE'
OR i.Category = 'Chemical' AND c.CategoryCode = 'CHEMICAL'
OR i.Category = 'Consumable' AND c.CategoryCode = 'CONSUMABLE'
OR i.Category = 'Tool' AND c.CategoryCode = 'TOOL'
OR i.Category = 'Other' AND c.CategoryCode = 'OTHER'
");
migrationBuilder.CreateIndex(
name: "IX_InventoryItems_InventoryCategoryId",
table: "InventoryItems",
column: "InventoryCategoryId");
migrationBuilder.CreateIndex(
name: "IX_InventoryCategoryLookups_CompanyId",
table: "InventoryCategoryLookups",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_InventoryCategoryLookups_CompanyId_CategoryCode",
table: "InventoryCategoryLookups",
columns: new[] { "CompanyId", "CategoryCode" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_InventoryItems_InventoryCategoryLookups_InventoryCategoryId",
table: "InventoryItems",
column: "InventoryCategoryId",
principalTable: "InventoryCategoryLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InventoryItems_InventoryCategoryLookups_InventoryCategoryId",
table: "InventoryItems");
migrationBuilder.DropTable(
name: "InventoryCategoryLookups");
migrationBuilder.DropIndex(
name: "IX_InventoryItems_InventoryCategoryId",
table: "InventoryItems");
migrationBuilder.DropColumn(
name: "InventoryCategoryId",
table: "InventoryItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6427));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6433));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 2, 38, 28, 726, DateTimeKind.Utc).AddTicks(6437));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddIsCoatingToInventoryCategory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsCoating",
table: "InventoryCategoryLookups",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7150));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7155));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7157));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsCoating",
table: "InventoryCategoryLookups");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1520));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1525));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 18, 25, 882, DateTimeKind.Utc).AddTicks(1527));
}
}
}
@@ -0,0 +1,124 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddQuoteChangeHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "QuoteChangeHistories",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuoteId = table.Column<int>(type: "int", nullable: false),
ChangedByUserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ChangedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
FieldName = table.Column<string>(type: "nvarchar(max)", nullable: false),
OldValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
NewValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
ChangeDescription = table.Column<string>(type: "nvarchar(max)", 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_QuoteChangeHistories", x => x.Id);
table.ForeignKey(
name: "FK_QuoteChangeHistories_AspNetUsers_ChangedByUserId",
column: x => x.ChangedByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_QuoteChangeHistories_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_QuoteChangeHistories_Quotes_QuoteId",
column: x => x.QuoteId,
principalTable: "Quotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2246));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2252));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2254));
migrationBuilder.CreateIndex(
name: "IX_QuoteChangeHistories_ChangedByUserId",
table: "QuoteChangeHistories",
column: "ChangedByUserId");
migrationBuilder.CreateIndex(
name: "IX_QuoteChangeHistories_CompanyId",
table: "QuoteChangeHistories",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_QuoteChangeHistories_QuoteId",
table: "QuoteChangeHistories",
column: "QuoteId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "QuoteChangeHistories");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7150));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7155));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 4, 46, 2, 489, DateTimeKind.Utc).AddTicks(7157));
}
}
}
@@ -0,0 +1,124 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJobChangeHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "JobChangeHistories",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobId = table.Column<int>(type: "int", nullable: false),
ChangedByUserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ChangedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
FieldName = table.Column<string>(type: "nvarchar(max)", nullable: false),
OldValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
NewValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
ChangeDescription = table.Column<string>(type: "nvarchar(max)", 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_JobChangeHistories", x => x.Id);
table.ForeignKey(
name: "FK_JobChangeHistories_AspNetUsers_ChangedByUserId",
column: x => x.ChangedByUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_JobChangeHistories_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_JobChangeHistories_Jobs_JobId",
column: x => x.JobId,
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3949));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3957));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3959));
migrationBuilder.CreateIndex(
name: "IX_JobChangeHistories_ChangedByUserId",
table: "JobChangeHistories",
column: "ChangedByUserId");
migrationBuilder.CreateIndex(
name: "IX_JobChangeHistories_CompanyId",
table: "JobChangeHistories",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_JobChangeHistories_JobId",
table: "JobChangeHistories",
column: "JobId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobChangeHistories");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2246));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2252));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 16, 34, 11, 975, DateTimeKind.Utc).AddTicks(2254));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMetricSystemPreference : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "UseMetricSystem",
table: "CompanyPreferences",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5899));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5906));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5907));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "UseMetricSystem",
table: "CompanyPreferences");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3949));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3957));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 17, 9, 52, 92, DateTimeKind.Utc).AddTicks(3959));
}
}
}
@@ -0,0 +1,218 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddAppointmentScheduling : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AppointmentStatusLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StatusCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "nvarchar(max)", nullable: false),
IconClass = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", nullable: false),
IsTerminalStatus = table.Column<bool>(type: "bit", nullable: false),
Description = 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_AppointmentStatusLookups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AppointmentTypeLookups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TypeCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
ColorClass = table.Column<string>(type: "nvarchar(max)", nullable: false),
IconClass = table.Column<string>(type: "nvarchar(max)", nullable: true),
RequiresJobLink = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
IsSystemDefined = table.Column<bool>(type: "bit", nullable: false),
Description = 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_AppointmentTypeLookups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Appointments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AppointmentNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
CustomerId = table.Column<int>(type: "int", nullable: false),
JobId = table.Column<int>(type: "int", nullable: true),
AppointmentStatusId = table.Column<int>(type: "int", nullable: false),
AppointmentTypeId = table.Column<int>(type: "int", nullable: false),
AssignedWorkerId = table.Column<int>(type: "int", nullable: true),
ScheduledStartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
ScheduledEndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
IsAllDay = table.Column<bool>(type: "bit", nullable: false),
ActualStartTime = table.Column<DateTime>(type: "datetime2", nullable: true),
ActualEndTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Location = table.Column<string>(type: "nvarchar(max)", nullable: true),
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsReminderEnabled = table.Column<bool>(type: "bit", nullable: false),
ReminderMinutesBefore = 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_Appointments", x => x.Id);
table.ForeignKey(
name: "FK_Appointments_AppointmentStatusLookups_AppointmentStatusId",
column: x => x.AppointmentStatusId,
principalTable: "AppointmentStatusLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Appointments_AppointmentTypeLookups_AppointmentTypeId",
column: x => x.AppointmentTypeId,
principalTable: "AppointmentTypeLookups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Appointments_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Appointments_Jobs_JobId",
column: x => x.JobId,
principalTable: "Jobs",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Appointments_ShopWorkers_AssignedWorkerId",
column: x => x.AssignedWorkerId,
principalTable: "ShopWorkers",
principalColumn: "Id");
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3342));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3348));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3349));
migrationBuilder.CreateIndex(
name: "IX_Appointments_AppointmentStatusId",
table: "Appointments",
column: "AppointmentStatusId");
migrationBuilder.CreateIndex(
name: "IX_Appointments_AppointmentTypeId",
table: "Appointments",
column: "AppointmentTypeId");
migrationBuilder.CreateIndex(
name: "IX_Appointments_AssignedWorkerId",
table: "Appointments",
column: "AssignedWorkerId");
migrationBuilder.CreateIndex(
name: "IX_Appointments_CustomerId",
table: "Appointments",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Appointments_JobId",
table: "Appointments",
column: "JobId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Appointments");
migrationBuilder.DropTable(
name: "AppointmentStatusLookups");
migrationBuilder.DropTable(
name: "AppointmentTypeLookups");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5899));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5906));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 18, 29, 1, 450, DateTimeKind.Utc).AddTicks(5907));
}
}
}
@@ -0,0 +1,102 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class MakeAppointmentCustomerIdOptional : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Appointments_Customers_CustomerId",
table: "Appointments");
migrationBuilder.AlterColumn<int>(
name: "CustomerId",
table: "Appointments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5144));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5153));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5155));
migrationBuilder.AddForeignKey(
name: "FK_Appointments_Customers_CustomerId",
table: "Appointments",
column: "CustomerId",
principalTable: "Customers",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Appointments_Customers_CustomerId",
table: "Appointments");
migrationBuilder.AlterColumn<int>(
name: "CustomerId",
table: "Appointments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3342));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3348));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 14, 22, 13, 31, 263, DateTimeKind.Utc).AddTicks(3349));
migrationBuilder.AddForeignKey(
name: "FK_Appointments_Customers_CustomerId",
table: "Appointments",
column: "CustomerId",
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -0,0 +1,138 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddAdditionalUserPermissions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "CanManageCalendar",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanManageEquipment",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanManageMaintenance",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanManageProducts",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanManageSuppliers",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanViewCalendar",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "CanViewProducts",
table: "AspNetUsers",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2987));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2995));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2997));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CanManageCalendar",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanManageEquipment",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanManageMaintenance",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanManageProducts",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanManageSuppliers",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanViewCalendar",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CanViewProducts",
table: "AspNetUsers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5144));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5153));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 5, 25, 692, DateTimeKind.Utc).AddTicks(5155));
}
}
}
@@ -0,0 +1,241 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPerformanceIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_JobPhotos_JobId",
table: "JobPhotos");
migrationBuilder.DropIndex(
name: "IX_JobNotes_JobId",
table: "JobNotes");
migrationBuilder.DropIndex(
name: "IX_CustomerNotes_CustomerId",
table: "CustomerNotes");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9644));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9650));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9652));
migrationBuilder.CreateIndex(
name: "IX_Quotes_CompanyId_ExpirationDate",
table: "Quotes",
columns: new[] { "CompanyId", "ExpirationDate" });
migrationBuilder.CreateIndex(
name: "IX_Quotes_CompanyId_QuoteStatusId",
table: "Quotes",
columns: new[] { "CompanyId", "QuoteStatusId" });
migrationBuilder.CreateIndex(
name: "IX_MaintenanceRecords_CompanyId_ScheduledDate",
table: "MaintenanceRecords",
columns: new[] { "CompanyId", "ScheduledDate" });
migrationBuilder.CreateIndex(
name: "IX_MaintenanceRecords_CompanyId_Status",
table: "MaintenanceRecords",
columns: new[] { "CompanyId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId_CustomerId",
table: "Jobs",
columns: new[] { "CompanyId", "CustomerId" });
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId_DueDate",
table: "Jobs",
columns: new[] { "CompanyId", "DueDate" });
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId_JobPriorityId",
table: "Jobs",
columns: new[] { "CompanyId", "JobPriorityId" });
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId_JobStatusId",
table: "Jobs",
columns: new[] { "CompanyId", "JobStatusId" });
migrationBuilder.CreateIndex(
name: "IX_Jobs_CompanyId_ScheduledDate",
table: "Jobs",
columns: new[] { "CompanyId", "ScheduledDate" });
migrationBuilder.CreateIndex(
name: "IX_JobPhotos_JobId_IsDeleted_DisplayOrder",
table: "JobPhotos",
columns: new[] { "JobId", "IsDeleted", "DisplayOrder" });
migrationBuilder.CreateIndex(
name: "IX_JobNotes_JobId_CreatedAt",
table: "JobNotes",
columns: new[] { "JobId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_JobItems_JobId_IsDeleted",
table: "JobItems",
columns: new[] { "JobId", "IsDeleted" });
migrationBuilder.CreateIndex(
name: "IX_InventoryItems_CompanyId_Quantity_Reorder",
table: "InventoryItems",
columns: new[] { "CompanyId", "QuantityOnHand", "ReorderPoint" });
migrationBuilder.CreateIndex(
name: "IX_Equipment_CompanyId_Status",
table: "Equipment",
columns: new[] { "CompanyId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_CustomerNotes_CustomerId_CreatedAt",
table: "CustomerNotes",
columns: new[] { "CustomerId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_Appointments_CompanyId_AppointmentStatusId",
table: "Appointments",
columns: new[] { "CompanyId", "AppointmentStatusId" });
migrationBuilder.CreateIndex(
name: "IX_Appointments_CompanyId_ScheduledStartTime",
table: "Appointments",
columns: new[] { "CompanyId", "ScheduledStartTime" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Quotes_CompanyId_ExpirationDate",
table: "Quotes");
migrationBuilder.DropIndex(
name: "IX_Quotes_CompanyId_QuoteStatusId",
table: "Quotes");
migrationBuilder.DropIndex(
name: "IX_MaintenanceRecords_CompanyId_ScheduledDate",
table: "MaintenanceRecords");
migrationBuilder.DropIndex(
name: "IX_MaintenanceRecords_CompanyId_Status",
table: "MaintenanceRecords");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId_CustomerId",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId_DueDate",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId_JobPriorityId",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId_JobStatusId",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Jobs_CompanyId_ScheduledDate",
table: "Jobs");
migrationBuilder.DropIndex(
name: "IX_JobPhotos_JobId_IsDeleted_DisplayOrder",
table: "JobPhotos");
migrationBuilder.DropIndex(
name: "IX_JobNotes_JobId_CreatedAt",
table: "JobNotes");
migrationBuilder.DropIndex(
name: "IX_JobItems_JobId_IsDeleted",
table: "JobItems");
migrationBuilder.DropIndex(
name: "IX_InventoryItems_CompanyId_Quantity_Reorder",
table: "InventoryItems");
migrationBuilder.DropIndex(
name: "IX_Equipment_CompanyId_Status",
table: "Equipment");
migrationBuilder.DropIndex(
name: "IX_CustomerNotes_CustomerId_CreatedAt",
table: "CustomerNotes");
migrationBuilder.DropIndex(
name: "IX_Appointments_CompanyId_AppointmentStatusId",
table: "Appointments");
migrationBuilder.DropIndex(
name: "IX_Appointments_CompanyId_ScheduledStartTime",
table: "Appointments");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2987));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2995));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 0, 34, 41, 233, DateTimeKind.Utc).AddTicks(2997));
migrationBuilder.CreateIndex(
name: "IX_JobPhotos_JobId",
table: "JobPhotos",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_JobNotes_JobId",
table: "JobNotes",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_CustomerNotes_CustomerId",
table: "CustomerNotes",
column: "CustomerId");
}
}
}
@@ -0,0 +1,201 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddQuoteItemCoatsSupport : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_QuoteItems_InventoryItems_InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropIndex(
name: "IX_QuoteItems_InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "ColorCode",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "ColorName",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "Finish",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "InventoryItemId",
table: "QuoteItems");
migrationBuilder.DropColumn(
name: "PowderCostOverride",
table: "QuoteItems");
migrationBuilder.CreateTable(
name: "QuoteItemCoats",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuoteItemId = 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),
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),
CoatMaterialCost = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
CoatLaborCost = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
CoatTotalCost = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
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_QuoteItemCoats", x => x.Id);
table.ForeignKey(
name: "FK_QuoteItemCoats_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_QuoteItemCoats_InventoryItems_InventoryItemId",
column: x => x.InventoryItemId,
principalTable: "InventoryItems",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_QuoteItemCoats_QuoteItems_QuoteItemId",
column: x => x.QuoteItemId,
principalTable: "QuoteItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9039));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9044));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9046));
migrationBuilder.CreateIndex(
name: "IX_QuoteItemCoats_CompanyId",
table: "QuoteItemCoats",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_QuoteItemCoats_InventoryItemId",
table: "QuoteItemCoats",
column: "InventoryItemId");
migrationBuilder.CreateIndex(
name: "IX_QuoteItemCoats_QuoteItemId",
table: "QuoteItemCoats",
column: "QuoteItemId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "QuoteItemCoats");
migrationBuilder.AddColumn<string>(
name: "ColorCode",
table: "QuoteItems",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ColorName",
table: "QuoteItems",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Finish",
table: "QuoteItems",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "InventoryItemId",
table: "QuoteItems",
type: "int",
nullable: true);
migrationBuilder.AddColumn<decimal>(
name: "PowderCostOverride",
table: "QuoteItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9644));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9650));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 5, 5, 35, 315, DateTimeKind.Utc).AddTicks(9652));
migrationBuilder.CreateIndex(
name: "IX_QuoteItems_InventoryItemId",
table: "QuoteItems",
column: "InventoryItemId");
migrationBuilder.AddForeignKey(
name: "FK_QuoteItems_InventoryItems_InventoryItemId",
table: "QuoteItems",
column: "InventoryItemId",
principalTable: "InventoryItems",
principalColumn: "Id");
}
}
}
@@ -0,0 +1,101 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPowderToOrderAndSupplierIdToQuoteItemCoat : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "PowderToOrder",
table: "QuoteItemCoats",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "SupplierId",
table: "QuoteItemCoats",
type: "int",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9459));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9465));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9467));
migrationBuilder.CreateIndex(
name: "IX_QuoteItemCoats_SupplierId",
table: "QuoteItemCoats",
column: "SupplierId");
migrationBuilder.AddForeignKey(
name: "FK_QuoteItemCoats_Suppliers_SupplierId",
table: "QuoteItemCoats",
column: "SupplierId",
principalTable: "Suppliers",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_QuoteItemCoats_Suppliers_SupplierId",
table: "QuoteItemCoats");
migrationBuilder.DropIndex(
name: "IX_QuoteItemCoats_SupplierId",
table: "QuoteItemCoats");
migrationBuilder.DropColumn(
name: "PowderToOrder",
table: "QuoteItemCoats");
migrationBuilder.DropColumn(
name: "SupplierId",
table: "QuoteItemCoats");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9039));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9044));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 15, 49, 0, 479, DateTimeKind.Utc).AddTicks(9046));
}
}
}
@@ -0,0 +1,72 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddAdditionalCoatLaborPercentToOperatingCosts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "AdditionalCoatLaborPercent",
table: "CompanyOperatingCosts",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9787));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9795));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9841));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AdditionalCoatLaborPercent",
table: "CompanyOperatingCosts");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9459));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9465));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 6, 37, 535, DateTimeKind.Utc).AddTicks(9467));
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddInternalNotesToJob : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "InternalNotes",
table: "Jobs",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9819));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9882));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9883));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "InternalNotes",
table: "Jobs");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9787));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9795));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 15, 23, 41, 19, 894, DateTimeKind.Utc).AddTicks(9841));
}
}
}
@@ -0,0 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class FixCustomerEmailUniqueIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Customers_Email",
table: "Customers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(829));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(834));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(836));
migrationBuilder.CreateIndex(
name: "IX_Customers_CompanyId_Email",
table: "Customers",
columns: new[] { "CompanyId", "Email" },
unique: true,
filter: "[Email] IS NOT NULL");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Customers_CompanyId_Email",
table: "Customers");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9819));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9882));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 16, 1, 11, 38, 601, DateTimeKind.Utc).AddTicks(9883));
migrationBuilder.CreateIndex(
name: "IX_Customers_Email",
table: "Customers",
column: "Email",
unique: true,
filter: "[Email] IS NOT NULL");
}
}
}
@@ -0,0 +1,139 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJobItemCoatEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "ActualTimeSpentHours",
table: "Jobs",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.CreateTable(
name: "JobItemCoats",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobItemId = 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),
SupplierId = 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),
PowderToOrder = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
ActualPowderUsedLbs = 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_JobItemCoats", x => x.Id);
table.ForeignKey(
name: "FK_JobItemCoats_InventoryItems_InventoryItemId",
column: x => x.InventoryItemId,
principalTable: "InventoryItems",
principalColumn: "Id");
table.ForeignKey(
name: "FK_JobItemCoats_JobItems_JobItemId",
column: x => x.JobItemId,
principalTable: "JobItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JobItemCoats_Suppliers_SupplierId",
column: x => x.SupplierId,
principalTable: "Suppliers",
principalColumn: "Id");
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6263));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6268));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6270));
migrationBuilder.CreateIndex(
name: "IX_JobItemCoats_InventoryItemId",
table: "JobItemCoats",
column: "InventoryItemId");
migrationBuilder.CreateIndex(
name: "IX_JobItemCoats_JobItemId",
table: "JobItemCoats",
column: "JobItemId");
migrationBuilder.CreateIndex(
name: "IX_JobItemCoats_SupplierId",
table: "JobItemCoats",
column: "SupplierId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobItemCoats");
migrationBuilder.DropColumn(
name: "ActualTimeSpentHours",
table: "Jobs");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(829));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(834));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 1, 53, 11, 919, DateTimeKind.Utc).AddTicks(836));
}
}
}
@@ -0,0 +1,93 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddQuoteDiscountFields : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DiscountReason",
table: "Quotes",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "DiscountType",
table: "Quotes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<decimal>(
name: "DiscountValue",
table: "Quotes",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5311));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5344));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5347));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DiscountReason",
table: "Quotes");
migrationBuilder.DropColumn(
name: "DiscountType",
table: "Quotes");
migrationBuilder.DropColumn(
name: "DiscountValue",
table: "Quotes");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6263));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6268));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 3, 17, 51, 702, DateTimeKind.Utc).AddTicks(6270));
}
}
}
@@ -0,0 +1,98 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJobDailyPriority : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "JobDailyPriorities",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobId = table.Column<int>(type: "int", nullable: false),
ScheduledDate = table.Column<DateTime>(type: "datetime2", nullable: false),
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_JobDailyPriorities", x => x.Id);
table.ForeignKey(
name: "FK_JobDailyPriorities_Jobs_JobId",
column: x => x.JobId,
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(473));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(480));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(482));
migrationBuilder.CreateIndex(
name: "IX_JobDailyPriorities_JobId",
table: "JobDailyPriorities",
column: "JobId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobDailyPriorities");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5311));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5344));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 5, 23, 38, 173, DateTimeKind.Utc).AddTicks(5347));
}
}
}
@@ -0,0 +1,83 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddRushJobToQuote : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsRushJob",
table: "Quotes",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<decimal>(
name: "RushFee",
table: "Quotes",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2836));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2841));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2843));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsRushJob",
table: "Quotes");
migrationBuilder.DropColumn(
name: "RushFee",
table: "Quotes");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(473));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(480));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 17, 5, 51, 546, DateTimeKind.Utc).AddTicks(482));
}
}
}
@@ -0,0 +1,88 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddPrepServicesTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PrepServices",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
DisplayOrder = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "bit", 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_PrepServices", x => x.Id);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6737));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6742));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6788));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PrepServices");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2836));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2841));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 17, 18, 54, 27, 774, DateTimeKind.Utc).AddTicks(2843));
}
}
}
@@ -0,0 +1,108 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddQuotePrepServiceRelationship : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "QuotePrepServices",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuoteId = table.Column<int>(type: "int", nullable: false),
PrepServiceId = 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_QuotePrepServices", x => x.Id);
table.ForeignKey(
name: "FK_QuotePrepServices_PrepServices_PrepServiceId",
column: x => x.PrepServiceId,
principalTable: "PrepServices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_QuotePrepServices_Quotes_QuoteId",
column: x => x.QuoteId,
principalTable: "Quotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3798));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3805));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3807));
migrationBuilder.CreateIndex(
name: "IX_QuotePrepServices_PrepServiceId",
table: "QuotePrepServices",
column: "PrepServiceId");
migrationBuilder.CreateIndex(
name: "IX_QuotePrepServices_QuoteId",
table: "QuotePrepServices",
column: "QuoteId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "QuotePrepServices");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6737));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6742));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 0, 44, 34, 426, DateTimeKind.Utc).AddTicks(6788));
}
}
}
@@ -0,0 +1,108 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJobPrepServices : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "JobPrepServices",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JobId = table.Column<int>(type: "int", nullable: false),
PrepServiceId = 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_JobPrepServices", x => x.Id);
table.ForeignKey(
name: "FK_JobPrepServices_Jobs_JobId",
column: x => x.JobId,
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JobPrepServices_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, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8224));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8229));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8231));
migrationBuilder.CreateIndex(
name: "IX_JobPrepServices_JobId",
table: "JobPrepServices",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_JobPrepServices_PrepServiceId",
table: "JobPrepServices",
column: "PrepServiceId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobPrepServices");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3798));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3805));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 1, 25, 320, DateTimeKind.Utc).AddTicks(3807));
}
}
}
@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddApproximateAreaToCatalogItem : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<decimal>(
name: "ApproximateArea",
table: "CatalogItems",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8277));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8282));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8284));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ApproximateArea",
table: "CatalogItems");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8224));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8229));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 1, 28, 57, 605, DateTimeKind.Utc).AddTicks(8231));
}
}
}
@@ -0,0 +1,132 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMaintenanceRecurrence : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsRecurring",
table: "MaintenanceRecords",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "RecurrenceEndDate",
table: "MaintenanceRecords",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "RecurrenceFrequency",
table: "MaintenanceRecords",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "RecurrenceGroupId",
table: "MaintenanceRecords",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "RecurrenceParentId",
table: "MaintenanceRecords",
type: "int",
nullable: true);
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 19, 14, 11, 2, 780, DateTimeKind.Utc).AddTicks(3625));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 19, 14, 11, 2, 780, DateTimeKind.Utc).AddTicks(3630));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 19, 14, 11, 2, 780, DateTimeKind.Utc).AddTicks(3632));
migrationBuilder.CreateIndex(
name: "IX_MaintenanceRecords_RecurrenceParentId",
table: "MaintenanceRecords",
column: "RecurrenceParentId");
migrationBuilder.AddForeignKey(
name: "FK_MaintenanceRecords_MaintenanceRecords_RecurrenceParentId",
table: "MaintenanceRecords",
column: "RecurrenceParentId",
principalTable: "MaintenanceRecords",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MaintenanceRecords_MaintenanceRecords_RecurrenceParentId",
table: "MaintenanceRecords");
migrationBuilder.DropIndex(
name: "IX_MaintenanceRecords_RecurrenceParentId",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "IsRecurring",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "RecurrenceEndDate",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "RecurrenceFrequency",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "RecurrenceGroupId",
table: "MaintenanceRecords");
migrationBuilder.DropColumn(
name: "RecurrenceParentId",
table: "MaintenanceRecords");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8277));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8282));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 2, 18, 2, 34, 9, 378, DateTimeKind.Utc).AddTicks(8284));
}
}
}

Some files were not shown because too many files have changed in this diff Show More