diff --git a/JobTrackerApi/Services/StartupInitializationExtensions.cs b/JobTrackerApi/Services/StartupInitializationExtensions.cs index 1cf1a36..cc0902b 100644 --- a/JobTrackerApi/Services/StartupInitializationExtensions.cs +++ b/JobTrackerApi/Services/StartupInitializationExtensions.cs @@ -773,12 +773,20 @@ public static class StartupInitializationExtensions "Id" INTEGER NOT NULL CONSTRAINT "PK_CareerProfiles" PRIMARY KEY AUTOINCREMENT, "OwnerUserId" TEXT NOT NULL, "ProfileJson" TEXT NOT NULL, + "LongTailJson" TEXT NOT NULL DEFAULT '', "Version" INTEGER NOT NULL, "CreatedAtUtc" TEXT NOT NULL, "UpdatedAtUtc" TEXT NOT NULL ); """); + // LongTailJson was added to the CareerProfile model (Phase 3) but this CREATE and + // the MySQL one were never updated to match, and no column-repair existed — so a + // CareerProfiles table created before this line lacks the column and /api/cv/outline + // (CareerProfileService.LoadStructuredAsync) fails with "Unknown column LongTailJson". + // Additive repair for existing databases. + EnsureColumn(c, "CareerProfiles", "LongTailJson", """ALTER TABLE "CareerProfiles" ADD COLUMN "LongTailJson" TEXT NOT NULL DEFAULT '';"""); + Exec(c, """ CREATE TABLE IF NOT EXISTS "CareerProfileVersions" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_CareerProfileVersions" PRIMARY KEY AUTOINCREMENT, @@ -1620,6 +1628,7 @@ public static class StartupInitializationExtensions `Id` int NOT NULL AUTO_INCREMENT, `OwnerUserId` varchar(255) NOT NULL, `ProfileJson` longtext NOT NULL, + `LongTailJson` longtext NOT NULL, `Version` int NOT NULL, `CreatedAtUtc` datetime(6) NOT NULL, `UpdatedAtUtc` datetime(6) NOT NULL, @@ -1628,6 +1637,11 @@ public static class StartupInitializationExtensions cmd.ExecuteNonQuery(); } + // Additive repair for a CareerProfiles table created before LongTailJson was added + // to the model. Without it, /api/cv/outline fails with "Unknown column LongTailJson". + // DEFAULT '' backfills existing rows and matches the non-nullable model property. + EnsureMySqlColumn(conn, "CareerProfiles", "LongTailJson", "ALTER TABLE `CareerProfiles` ADD COLUMN `LongTailJson` longtext NOT NULL DEFAULT '';"); + if (!HasMySqlTable(conn, "CareerProfileVersions") && HasMySqlTable(conn, "CareerProfiles")) { using var cmd = conn.CreateCommand();