using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace PowderCoating.Infrastructure.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetUsers", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), FirstName = table.Column(type: "nvarchar(max)", nullable: false), LastName = table.Column(type: "nvarchar(max)", nullable: false), EmployeeNumber = table.Column(type: "nvarchar(max)", nullable: true), DateOfBirth = table.Column(type: "datetime2", nullable: true), HireDate = table.Column(type: "datetime2", nullable: false), TerminationDate = table.Column(type: "datetime2", nullable: true), Address = table.Column(type: "nvarchar(max)", nullable: true), City = table.Column(type: "nvarchar(max)", nullable: true), State = table.Column(type: "nvarchar(max)", nullable: true), ZipCode = table.Column(type: "nvarchar(max)", nullable: true), Department = table.Column(type: "nvarchar(max)", nullable: true), Position = table.Column(type: "nvarchar(max)", nullable: true), HourlyRate = table.Column(type: "decimal(18,2)", nullable: false), Theme = table.Column(type: "nvarchar(max)", nullable: true), DateFormat = table.Column(type: "nvarchar(max)", nullable: true), TimeZone = table.Column(type: "nvarchar(max)", nullable: true), DashboardLayout = table.Column(type: "int", nullable: true), IsActive = table.Column(type: "bit", nullable: false), CanViewShopFloor = table.Column(type: "bit", nullable: false), CanManageJobs = table.Column(type: "bit", nullable: false), CanManageInventory = table.Column(type: "bit", nullable: false), CanManageCustomers = table.Column(type: "bit", nullable: false), CanCreateQuotes = table.Column(type: "bit", nullable: false), CanApproveQuotes = table.Column(type: "bit", nullable: false), ProfilePicturePath = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), LastLoginDate = table.Column(type: "datetime2", nullable: true), UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), EmailConfirmed = table.Column(type: "bit", nullable: false), PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), TwoFactorEnabled = table.Column(type: "bit", nullable: false), LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), LockoutEnabled = table.Column(type: "bit", nullable: false), AccessFailedCount = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); }); migrationBuilder.CreateTable( name: "Equipment", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), EquipmentName = table.Column(type: "nvarchar(max)", nullable: false), EquipmentNumber = table.Column(type: "nvarchar(max)", nullable: true), EquipmentType = table.Column(type: "nvarchar(max)", nullable: false), Manufacturer = table.Column(type: "nvarchar(max)", nullable: true), Model = table.Column(type: "nvarchar(max)", nullable: true), SerialNumber = table.Column(type: "nvarchar(max)", nullable: true), PurchaseDate = table.Column(type: "datetime2", nullable: true), PurchasePrice = table.Column(type: "decimal(18,2)", nullable: false), WarrantyExpiration = table.Column(type: "datetime2", nullable: true), Status = table.Column(type: "int", nullable: false), Location = table.Column(type: "nvarchar(max)", nullable: true), RecommendedMaintenanceIntervalDays = table.Column(type: "int", nullable: false), LastMaintenanceDate = table.Column(type: "datetime2", nullable: true), NextScheduledMaintenance = table.Column(type: "datetime2", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Equipment", x => x.Id); }); migrationBuilder.CreateTable( name: "PricingTiers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), TierName = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), DiscountPercent = table.Column(type: "decimal(18,2)", nullable: false), IsActive = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_PricingTiers", x => x.Id); }); migrationBuilder.CreateTable( name: "Suppliers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CompanyName = table.Column(type: "nvarchar(max)", nullable: false), ContactName = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(max)", nullable: true), Phone = table.Column(type: "nvarchar(max)", nullable: true), Address = table.Column(type: "nvarchar(max)", nullable: true), City = table.Column(type: "nvarchar(max)", nullable: true), State = table.Column(type: "nvarchar(max)", nullable: true), ZipCode = table.Column(type: "nvarchar(max)", nullable: true), Country = table.Column(type: "nvarchar(max)", nullable: true), Website = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Suppliers", x => x.Id); }); migrationBuilder.CreateTable( name: "AspNetRoleClaims", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RoleId = table.Column(type: "nvarchar(450)", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserClaims", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), UserId = table.Column(type: "nvarchar(450)", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); table.ForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserLogins", columns: table => new { LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), UserId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); table.ForeignKey( name: "FK_AspNetUserLogins_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserRoles", columns: table => new { UserId = table.Column(type: "nvarchar(450)", nullable: false), RoleId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetRoles_RoleId", column: x => x.RoleId, principalTable: "AspNetRoles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AspNetUserRoles_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AspNetUserTokens", columns: table => new { UserId = table.Column(type: "nvarchar(450)", nullable: false), LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(450)", nullable: false), Value = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); table.ForeignKey( name: "FK_AspNetUserTokens_AspNetUsers_UserId", column: x => x.UserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MaintenanceRecords", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), EquipmentId = table.Column(type: "int", nullable: false), MaintenanceType = table.Column(type: "nvarchar(max)", nullable: false), Status = table.Column(type: "int", nullable: false), Priority = table.Column(type: "int", nullable: false), ScheduledDate = table.Column(type: "datetime2", nullable: false), CompletedDate = table.Column(type: "datetime2", nullable: true), PerformedById = table.Column(type: "nvarchar(450)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: false), WorkPerformed = table.Column(type: "nvarchar(max)", nullable: true), PartsReplaced = table.Column(type: "nvarchar(max)", nullable: true), LaborCost = table.Column(type: "decimal(18,2)", nullable: false), PartsCost = table.Column(type: "decimal(18,2)", nullable: false), TotalCost = table.Column(type: "decimal(18,2)", nullable: false), DowntimeHours = table.Column(type: "decimal(18,2)", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), TechnicianNotes = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_MaintenanceRecords", x => x.Id); table.ForeignKey( name: "FK_MaintenanceRecords_AspNetUsers_PerformedById", column: x => x.PerformedById, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_MaintenanceRecords_Equipment_EquipmentId", column: x => x.EquipmentId, principalTable: "Equipment", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Customers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CompanyName = table.Column(type: "nvarchar(450)", nullable: false), ContactFirstName = table.Column(type: "nvarchar(max)", nullable: true), ContactLastName = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(450)", nullable: false), Phone = table.Column(type: "nvarchar(max)", nullable: true), MobilePhone = table.Column(type: "nvarchar(max)", nullable: true), Address = table.Column(type: "nvarchar(max)", nullable: true), City = table.Column(type: "nvarchar(max)", nullable: true), State = table.Column(type: "nvarchar(max)", nullable: true), ZipCode = table.Column(type: "nvarchar(max)", nullable: true), Country = table.Column(type: "nvarchar(max)", nullable: true), IsCommercial = table.Column(type: "bit", nullable: false), TaxId = table.Column(type: "nvarchar(max)", nullable: true), CreditLimit = table.Column(type: "decimal(18,2)", nullable: false), CurrentBalance = table.Column(type: "decimal(18,2)", nullable: false), PaymentTerms = table.Column(type: "nvarchar(max)", nullable: true), PricingTierId = table.Column(type: "int", nullable: true), GeneralNotes = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), LastContactDate = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Customers", x => x.Id); table.ForeignKey( name: "FK_Customers_PricingTiers_PricingTierId", column: x => x.PricingTierId, principalTable: "PricingTiers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateTable( name: "InventoryItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SKU = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), Category = table.Column(type: "nvarchar(max)", nullable: false), ColorName = table.Column(type: "nvarchar(max)", nullable: true), ColorCode = table.Column(type: "nvarchar(max)", nullable: true), Finish = table.Column(type: "nvarchar(max)", nullable: true), Manufacturer = table.Column(type: "nvarchar(max)", nullable: true), ManufacturerPartNumber = table.Column(type: "nvarchar(max)", nullable: true), QuantityOnHand = table.Column(type: "decimal(18,2)", nullable: false), UnitOfMeasure = table.Column(type: "nvarchar(max)", nullable: false), ReorderPoint = table.Column(type: "decimal(18,2)", nullable: false), ReorderQuantity = table.Column(type: "decimal(18,2)", nullable: false), MinimumStock = table.Column(type: "decimal(18,2)", nullable: false), MaximumStock = table.Column(type: "decimal(18,2)", nullable: false), UnitCost = table.Column(type: "decimal(18,2)", nullable: false), AverageCost = table.Column(type: "decimal(18,2)", nullable: false), LastPurchasePrice = table.Column(type: "decimal(18,2)", nullable: false), LastPurchaseDate = table.Column(type: "datetime2", nullable: true), PrimarySupplierId = table.Column(type: "int", nullable: true), SupplierPartNumber = table.Column(type: "nvarchar(max)", nullable: true), Location = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), DiscontinuedDate = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_InventoryItems", x => x.Id); table.ForeignKey( name: "FK_InventoryItems_Suppliers_PrimarySupplierId", column: x => x.PrimarySupplierId, principalTable: "Suppliers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateTable( name: "CustomerNotes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CustomerId = table.Column(type: "int", nullable: false), Note = table.Column(type: "nvarchar(max)", nullable: false), IsImportant = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_CustomerNotes", x => x.Id); table.ForeignKey( name: "FK_CustomerNotes_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Quotes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), QuoteNumber = table.Column(type: "nvarchar(450)", nullable: false), CustomerId = table.Column(type: "int", nullable: false), PreparedById = table.Column(type: "nvarchar(450)", nullable: true), Status = table.Column(type: "int", nullable: false), IsCommercial = table.Column(type: "bit", nullable: false), QuoteDate = table.Column(type: "datetime2", nullable: false), ExpirationDate = table.Column(type: "datetime2", nullable: true), SentDate = table.Column(type: "datetime2", nullable: true), ApprovedDate = table.Column(type: "datetime2", nullable: true), SubTotal = table.Column(type: "decimal(18,2)", nullable: false), DiscountPercent = table.Column(type: "decimal(18,2)", nullable: false), DiscountAmount = table.Column(type: "decimal(18,2)", nullable: false), TaxPercent = table.Column(type: "decimal(18,2)", nullable: false), TaxAmount = table.Column(type: "decimal(18,2)", nullable: false), Total = table.Column(type: "decimal(18,2)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), Terms = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), CustomerPO = table.Column(type: "nvarchar(max)", nullable: true), AISuggestedPrice = table.Column(type: "decimal(18,2)", nullable: true), AIPriceRationale = table.Column(type: "nvarchar(max)", nullable: true), UsedAISuggestion = table.Column(type: "bit", nullable: false), ConvertedToJobId = table.Column(type: "int", nullable: true), ConvertedDate = table.Column(type: "datetime2", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Quotes", x => x.Id); table.ForeignKey( name: "FK_Quotes_AspNetUsers_PreparedById", column: x => x.PreparedById, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_Quotes_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "InventoryTransactions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), InventoryItemId = table.Column(type: "int", nullable: false), TransactionType = table.Column(type: "int", nullable: false), Quantity = table.Column(type: "decimal(18,2)", nullable: false), UnitCost = table.Column(type: "decimal(18,2)", nullable: false), TotalCost = table.Column(type: "decimal(18,2)", nullable: false), TransactionDate = table.Column(type: "datetime2", nullable: false), Reference = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), BalanceAfter = table.Column(type: "decimal(18,2)", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_InventoryTransactions", x => x.Id); table.ForeignKey( name: "FK_InventoryTransactions_InventoryItems_InventoryItemId", column: x => x.InventoryItemId, principalTable: "InventoryItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Jobs", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobNumber = table.Column(type: "nvarchar(450)", nullable: false), CustomerId = table.Column(type: "int", nullable: false), QuoteId = table.Column(type: "int", nullable: true), AssignedEmployeeId = table.Column(type: "nvarchar(450)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: false), Status = table.Column(type: "int", nullable: false), Priority = table.Column(type: "int", nullable: false), ScheduledDate = table.Column(type: "datetime2", nullable: true), StartedDate = table.Column(type: "datetime2", nullable: true), CompletedDate = table.Column(type: "datetime2", nullable: true), DueDate = table.Column(type: "datetime2", nullable: true), EstimatedCost = table.Column(type: "decimal(18,2)", nullable: false), ActualCost = table.Column(type: "decimal(18,2)", nullable: false), QuotedPrice = table.Column(type: "decimal(18,2)", nullable: false), FinalPrice = table.Column(type: "decimal(18,2)", nullable: false), CustomerPO = table.Column(type: "nvarchar(max)", nullable: true), SpecialInstructions = table.Column(type: "nvarchar(max)", nullable: true), RequiresCustomerApproval = table.Column(type: "bit", nullable: false), IsCustomerApproved = table.Column(type: "bit", nullable: false), CustomerApprovedDate = table.Column(type: "datetime2", nullable: true), EstimatedHours = table.Column(type: "int", nullable: false), ActualHours = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Jobs", x => x.Id); table.ForeignKey( name: "FK_Jobs_AspNetUsers_AssignedEmployeeId", column: x => x.AssignedEmployeeId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_Jobs_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_Jobs_Quotes_QuoteId", column: x => x.QuoteId, principalTable: "Quotes", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateTable( name: "QuoteItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), QuoteId = table.Column(type: "int", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Quantity = table.Column(type: "int", nullable: false), ColorName = table.Column(type: "nvarchar(max)", nullable: true), ColorCode = table.Column(type: "nvarchar(max)", nullable: true), Finish = table.Column(type: "nvarchar(max)", nullable: true), Length = table.Column(type: "decimal(18,2)", nullable: true), Width = table.Column(type: "decimal(18,2)", nullable: true), Height = table.Column(type: "decimal(18,2)", nullable: true), SurfaceArea = table.Column(type: "decimal(18,2)", nullable: true), MeasurementUnit = table.Column(type: "nvarchar(max)", nullable: true), UnitPrice = table.Column(type: "decimal(18,2)", nullable: false), TotalPrice = table.Column(type: "decimal(18,2)", nullable: false), RequiresSandblasting = table.Column(type: "bit", nullable: false), RequiresMasking = table.Column(type: "bit", nullable: false), EstimatedMinutes = table.Column(type: "int", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_QuoteItems", x => x.Id); table.ForeignKey( name: "FK_QuoteItems_Quotes_QuoteId", column: x => x.QuoteId, principalTable: "Quotes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "JobItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Quantity = table.Column(type: "int", nullable: false), PowderInventoryId = table.Column(type: "int", nullable: true), ColorName = table.Column(type: "nvarchar(max)", nullable: true), ColorCode = table.Column(type: "nvarchar(max)", nullable: true), Finish = table.Column(type: "nvarchar(max)", nullable: true), Length = table.Column(type: "decimal(18,2)", nullable: true), Width = table.Column(type: "decimal(18,2)", nullable: true), Height = table.Column(type: "decimal(18,2)", nullable: true), Weight = table.Column(type: "decimal(18,2)", nullable: true), SurfaceArea = table.Column(type: "decimal(18,2)", nullable: true), MeasurementUnit = table.Column(type: "nvarchar(max)", nullable: true), UnitPrice = table.Column(type: "decimal(18,2)", nullable: false), TotalPrice = table.Column(type: "decimal(18,2)", nullable: false), MaterialCost = table.Column(type: "decimal(18,2)", nullable: false), LaborCost = table.Column(type: "decimal(18,2)", nullable: false), RequiresSandblasting = table.Column(type: "bit", nullable: false), RequiresMasking = table.Column(type: "bit", nullable: false), EstimatedMinutes = table.Column(type: "int", nullable: false), ActualMinutes = table.Column(type: "int", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_JobItems", x => x.Id); table.ForeignKey( name: "FK_JobItems_InventoryItems_PowderInventoryId", column: x => x.PowderInventoryId, principalTable: "InventoryItems", principalColumn: "Id"); table.ForeignKey( name: "FK_JobItems_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "JobNotes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: false), Note = table.Column(type: "nvarchar(max)", nullable: false), IsImportant = table.Column(type: "bit", nullable: false), IsInternal = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_JobNotes", x => x.Id); table.ForeignKey( name: "FK_JobNotes_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "JobPhotos", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: false), FileName = table.Column(type: "nvarchar(max)", nullable: false), FilePath = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), PhotoType = table.Column(type: "nvarchar(max)", nullable: false), PhotoDate = table.Column(type: "datetime2", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_JobPhotos", x => x.Id); table.ForeignKey( name: "FK_JobPhotos_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "JobStatusHistory", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: false), FromStatus = table.Column(type: "int", nullable: false), ToStatus = table.Column(type: "int", nullable: false), ChangedDate = table.Column(type: "datetime2", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_JobStatusHistory", x => x.Id); table.ForeignKey( name: "FK_JobStatusHistory_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "PricingTiers", columns: new[] { "Id", "CreatedAt", "CreatedBy", "DeletedAt", "DeletedBy", "Description", "DiscountPercent", "IsActive", "IsDeleted", "TierName", "UpdatedAt", "UpdatedBy" }, values: new object[,] { { 1, new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1418), null, null, null, "Standard pricing for regular customers", 0m, true, false, "Standard", null, null }, { 2, new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1424), null, null, null, "5% discount for preferred customers", 5m, true, false, "Preferred", null, null }, { 3, new DateTime(2026, 2, 5, 16, 37, 50, 175, DateTimeKind.Utc).AddTicks(1426), null, null, null, "10% discount for premium customers", 10m, true, false, "Premium", null, null } }); migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", column: "RoleId"); migrationBuilder.CreateIndex( name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", unique: true, filter: "[NormalizedName] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", table: "AspNetUserClaims", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserLogins_UserId", table: "AspNetUserLogins", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_AspNetUserRoles_RoleId", table: "AspNetUserRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "EmailIndex", table: "AspNetUsers", column: "NormalizedEmail"); migrationBuilder.CreateIndex( name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", unique: true, filter: "[NormalizedUserName] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_CustomerNotes_CustomerId", table: "CustomerNotes", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_Customers_CompanyName", table: "Customers", column: "CompanyName"); migrationBuilder.CreateIndex( name: "IX_Customers_Email", table: "Customers", column: "Email", unique: true); migrationBuilder.CreateIndex( name: "IX_Customers_PricingTierId", table: "Customers", column: "PricingTierId"); migrationBuilder.CreateIndex( name: "IX_InventoryItems_PrimarySupplierId", table: "InventoryItems", column: "PrimarySupplierId"); migrationBuilder.CreateIndex( name: "IX_InventoryItems_SKU", table: "InventoryItems", column: "SKU", unique: true); migrationBuilder.CreateIndex( name: "IX_InventoryTransactions_InventoryItemId", table: "InventoryTransactions", column: "InventoryItemId"); migrationBuilder.CreateIndex( name: "IX_JobItems_JobId", table: "JobItems", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_JobItems_PowderInventoryId", table: "JobItems", column: "PowderInventoryId"); migrationBuilder.CreateIndex( name: "IX_JobNotes_JobId", table: "JobNotes", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_JobPhotos_JobId", table: "JobPhotos", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_Jobs_AssignedEmployeeId", table: "Jobs", column: "AssignedEmployeeId"); migrationBuilder.CreateIndex( name: "IX_Jobs_CustomerId", table: "Jobs", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_Jobs_JobNumber", table: "Jobs", column: "JobNumber", unique: true); migrationBuilder.CreateIndex( name: "IX_Jobs_QuoteId", table: "Jobs", column: "QuoteId", unique: true, filter: "[QuoteId] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_JobStatusHistory_JobId", table: "JobStatusHistory", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_MaintenanceRecords_EquipmentId", table: "MaintenanceRecords", column: "EquipmentId"); migrationBuilder.CreateIndex( name: "IX_MaintenanceRecords_PerformedById", table: "MaintenanceRecords", column: "PerformedById"); migrationBuilder.CreateIndex( name: "IX_QuoteItems_QuoteId", table: "QuoteItems", column: "QuoteId"); migrationBuilder.CreateIndex( name: "IX_Quotes_CustomerId", table: "Quotes", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_Quotes_PreparedById", table: "Quotes", column: "PreparedById"); migrationBuilder.CreateIndex( name: "IX_Quotes_QuoteNumber", table: "Quotes", column: "QuoteNumber", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AspNetRoleClaims"); migrationBuilder.DropTable( name: "AspNetUserClaims"); migrationBuilder.DropTable( name: "AspNetUserLogins"); migrationBuilder.DropTable( name: "AspNetUserRoles"); migrationBuilder.DropTable( name: "AspNetUserTokens"); migrationBuilder.DropTable( name: "CustomerNotes"); migrationBuilder.DropTable( name: "InventoryTransactions"); migrationBuilder.DropTable( name: "JobItems"); migrationBuilder.DropTable( name: "JobNotes"); migrationBuilder.DropTable( name: "JobPhotos"); migrationBuilder.DropTable( name: "JobStatusHistory"); migrationBuilder.DropTable( name: "MaintenanceRecords"); migrationBuilder.DropTable( name: "QuoteItems"); migrationBuilder.DropTable( name: "AspNetRoles"); migrationBuilder.DropTable( name: "InventoryItems"); migrationBuilder.DropTable( name: "Jobs"); migrationBuilder.DropTable( name: "Equipment"); migrationBuilder.DropTable( name: "Suppliers"); migrationBuilder.DropTable( name: "Quotes"); migrationBuilder.DropTable( name: "AspNetUsers"); migrationBuilder.DropTable( name: "Customers"); migrationBuilder.DropTable( name: "PricingTiers"); } } }