fix(cv): add LongTailJson to reconciler CareerProfiles schema
Production GET /api/cv/outline returned 500 "Unknown column 'c.LongTailJson'". CareerProfiles is reconciler-owned, but the reconciler's CREATE TABLE (both the SQLite and MySQL branches) only listed Id, OwnerUserId, ProfileJson, Version, CreatedAtUtc, UpdatedAtUtc. LongTailJson was added to the CareerProfile model in Phase 3 but neither CREATE was updated and no column-repair existed, so: - existing databases (prod): the MySQL CREATE is guarded on !HasMySqlTable, so it never runs once the table exists, and nothing adds the column -> LoadStructuredAsync selects a column that isn't there. - fresh databases: the CREATE itself omitted the column, so even a brand new MariaDB/SQLite was missing it. The 420 tests never caught this because they build tables from the EF model, not the reconciler DDL. The release audit missed it because it never exercised /api/cv/outline. Add LongTailJson to both CREATE statements and add an additive repair (EnsureColumn / EnsureMySqlColumn) for existing tables. DEFAULT '' backfills existing rows and matches the non-nullable model property. This is the sanctioned reconciler repair path, not a manual ALTER, and preserves existing data (ADD COLUMN is non-destructive). Verified on a real MariaDB 11 container: an existing 6-column CareerProfiles gains LongTailJson on startup (repair path), a fresh DB gets it from the CREATE (longtext), and GET /api/cv/outline returns 200. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user