using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddShopWorkers : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "AssignedWorkerId", table: "MaintenanceRecords", type: "int", nullable: true); migrationBuilder.AddColumn( name: "AssignedWorkerId", table: "Jobs", type: "int", nullable: true); migrationBuilder.CreateTable( name: "ShopWorkers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Role = table.Column(type: "int", nullable: false), Phone = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), Notes = table.Column(type: "nvarchar(max)", nullable: true), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_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); } /// 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)); } } }