using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddAppointmentScheduling : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AppointmentStatusLookups", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), StatusCode = table.Column(type: "nvarchar(max)", nullable: false), DisplayName = table.Column(type: "nvarchar(max)", nullable: false), DisplayOrder = table.Column(type: "int", nullable: false), ColorClass = table.Column(type: "nvarchar(max)", nullable: false), IconClass = table.Column(type: "nvarchar(max)", nullable: true), IsActive = table.Column(type: "bit", nullable: false), IsSystemDefined = table.Column(type: "bit", nullable: false), IsTerminalStatus = table.Column(type: "bit", nullable: false), Description = 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_AppointmentStatusLookups", x => x.Id); }); migrationBuilder.CreateTable( name: "AppointmentTypeLookups", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), TypeCode = table.Column(type: "nvarchar(max)", nullable: false), DisplayName = table.Column(type: "nvarchar(max)", nullable: false), DisplayOrder = table.Column(type: "int", nullable: false), ColorClass = table.Column(type: "nvarchar(max)", nullable: false), IconClass = table.Column(type: "nvarchar(max)", nullable: true), RequiresJobLink = table.Column(type: "bit", nullable: false), IsActive = table.Column(type: "bit", nullable: false), IsSystemDefined = table.Column(type: "bit", nullable: false), Description = 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_AppointmentTypeLookups", x => x.Id); }); migrationBuilder.CreateTable( name: "Appointments", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AppointmentNumber = table.Column(type: "nvarchar(max)", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), CustomerId = table.Column(type: "int", nullable: false), JobId = table.Column(type: "int", nullable: true), AppointmentStatusId = table.Column(type: "int", nullable: false), AppointmentTypeId = table.Column(type: "int", nullable: false), AssignedWorkerId = table.Column(type: "int", nullable: true), ScheduledStartTime = table.Column(type: "datetime2", nullable: false), ScheduledEndTime = table.Column(type: "datetime2", nullable: false), IsAllDay = table.Column(type: "bit", nullable: false), ActualStartTime = table.Column(type: "datetime2", nullable: true), ActualEndTime = table.Column(type: "datetime2", nullable: true), Location = table.Column(type: "nvarchar(max)", nullable: true), Notes = table.Column(type: "nvarchar(max)", nullable: true), IsReminderEnabled = table.Column(type: "bit", nullable: false), ReminderMinutesBefore = table.Column(type: "int", nullable: false), CompanyId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true), CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true), IsDeleted = table.Column(type: "bit", nullable: false), DeletedAt = table.Column(type: "datetime2", nullable: true), DeletedBy = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_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"); } /// 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)); } } }