using System; using JobTrackerApi.Data; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace JobTrackerApi.Migrations; /// /// Moves Gmail review-decision creation into the migration chain and supplies the previously /// missing MariaDB table while retaining SQLite rows created by startup reconciliation. /// [DbContext(typeof(JobTrackerContext))] [Migration("20260830122000_AdoptGmailReviewDecisionsSchema")] public sealed class AdoptGmailReviewDecisionsSchema : Migration { protected override void Up(MigrationBuilder migrationBuilder) { if (ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase)) { migrationBuilder.Sql(""" CREATE TABLE IF NOT EXISTS `GmailReviewDecisions` ( `Id` int NOT NULL AUTO_INCREMENT, `OwnerUserId` varchar(255) NOT NULL, `ThreadId` varchar(512) NOT NULL, `JobApplicationId` int NULL, `Decision` varchar(32) NOT NULL, `Note` longtext NULL, `UpdatedAt` datetime(6) NOT NULL, PRIMARY KEY (`Id`) ) CHARACTER SET=utf8mb4; """); return; } migrationBuilder.Sql(""" CREATE TABLE IF NOT EXISTS "GmailReviewDecisions" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_GmailReviewDecisions" PRIMARY KEY AUTOINCREMENT, "OwnerUserId" TEXT NOT NULL, "ThreadId" TEXT NOT NULL, "JobApplicationId" INTEGER NULL, "Decision" TEXT NOT NULL, "Note" TEXT NULL, "UpdatedAt" TEXT NOT NULL ); """); } protected override void Down(MigrationBuilder migrationBuilder) { // Preserve decisions that may have been created before migration ownership was introduced. } }