using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddReworkTracking : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "IsReworkJob", table: "Jobs", type: "bit", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "OriginalJobId", table: "Jobs", type: "int", nullable: true); migrationBuilder.CreateTable( name: "ReworkRecords", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: false), JobItemId = table.Column(type: "int", nullable: true), ReworkJobId = table.Column(type: "int", nullable: true), ReworkType = table.Column(type: "int", nullable: false), Reason = table.Column(type: "int", nullable: false), DefectDescription = table.Column(type: "nvarchar(max)", nullable: false), DiscoveredBy = table.Column(type: "int", nullable: false), DiscoveredDate = table.Column(type: "datetime2", nullable: false), ReportedByName = table.Column(type: "nvarchar(max)", nullable: true), EstimatedReworkCost = table.Column(type: "decimal(18,2)", nullable: false), ActualReworkCost = table.Column(type: "decimal(18,2)", nullable: false), IsBillableToCustomer = table.Column(type: "bit", nullable: false), BillingNotes = table.Column(type: "nvarchar(max)", nullable: true), Status = table.Column(type: "int", nullable: false), Resolution = table.Column(type: "int", nullable: true), ResolvedDate = table.Column(type: "datetime2", nullable: true), ResolutionNotes = table.Column(type: "nvarchar(max)", nullable: true), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ReworkRecords", x => x.Id); table.ForeignKey( name: "FK_ReworkRecords_JobItems_JobItemId", column: x => x.JobItemId, principalTable: "JobItems", principalColumn: "Id"); table.ForeignKey( name: "FK_ReworkRecords_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ReworkRecords_Jobs_ReworkJobId", column: x => x.ReworkJobId, principalTable: "Jobs", principalColumn: "Id"); }); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 42, 32, 909, DateTimeKind.Utc).AddTicks(2998)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 42, 32, 909, DateTimeKind.Utc).AddTicks(3003)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 42, 32, 909, DateTimeKind.Utc).AddTicks(3005)); migrationBuilder.CreateIndex( name: "IX_Jobs_OriginalJobId", table: "Jobs", column: "OriginalJobId"); migrationBuilder.CreateIndex( name: "IX_ReworkRecords_JobId", table: "ReworkRecords", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_ReworkRecords_JobItemId", table: "ReworkRecords", column: "JobItemId"); migrationBuilder.CreateIndex( name: "IX_ReworkRecords_ReworkJobId", table: "ReworkRecords", column: "ReworkJobId"); migrationBuilder.AddForeignKey( name: "FK_Jobs_Jobs_OriginalJobId", table: "Jobs", column: "OriginalJobId", principalTable: "Jobs", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Jobs_Jobs_OriginalJobId", table: "Jobs"); migrationBuilder.DropTable( name: "ReworkRecords"); migrationBuilder.DropIndex( name: "IX_Jobs_OriginalJobId", table: "Jobs"); migrationBuilder.DropColumn( name: "IsReworkJob", table: "Jobs"); migrationBuilder.DropColumn( name: "OriginalJobId", table: "Jobs"); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 28, 54, 685, DateTimeKind.Utc).AddTicks(4802)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 28, 54, 685, DateTimeKind.Utc).AddTicks(4849)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 3, 18, 13, 28, 54, 685, DateTimeKind.Utc).AddTicks(4851)); } } }