From ee4fa55c1e71af3b3ecd092eb343ef469b1d6539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 27 Jun 2026 15:46:03 +0200 Subject: [PATCH] fix(db): target the users table in the v1.22 AI-settings migration The AI-settings migration altered "User" but the table is "users"; deploy would abort with relation "User" does not exist. Correct the identifier and make both v1.22 column additions rerun-safe with IF NOT EXISTS. --- .../0197_coach_plan_outcome/migration.sql | 2 +- .../migrations/0198_v122_ai_settings/migration.sql | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/prisma/migrations/0197_coach_plan_outcome/migration.sql b/prisma/migrations/0197_coach_plan_outcome/migration.sql index fa0d848ab..1a8ea6d9d 100644 --- a/prisma/migrations/0197_coach_plan_outcome/migration.sql +++ b/prisma/migrations/0197_coach_plan_outcome/migration.sql @@ -3,4 +3,4 @@ -- processed, the grounded before/after result is written here. Additive, -- nullable Bytes column — no backfill, no enum change (the new statuses -- review_due / reviewed are app-side strings on the existing `status` column). -ALTER TABLE "coach_plans" ADD COLUMN "outcome_encrypted" BYTEA; +ALTER TABLE "coach_plans" ADD COLUMN IF NOT EXISTS "outcome_encrypted" BYTEA; diff --git a/prisma/migrations/0198_v122_ai_settings/migration.sql b/prisma/migrations/0198_v122_ai_settings/migration.sql index d74386379..65c345959 100644 --- a/prisma/migrations/0198_v122_ai_settings/migration.sql +++ b/prisma/migrations/0198_v122_ai_settings/migration.sql @@ -17,10 +17,10 @@ -- encrypted-columns registry + the rotation script). -- -- All columns are nullable / defaulted, so existing rows need no backfill. -ALTER TABLE "User" - ADD COLUMN "ai_response_timeout_seconds" INTEGER, - ADD COLUMN "ai_ocr_enabled" BOOLEAN NOT NULL DEFAULT false, - ADD COLUMN "ai_ocr_provider" TEXT, - ADD COLUMN "ai_ocr_model" TEXT, - ADD COLUMN "ai_ocr_base_url" TEXT, - ADD COLUMN "ai_ocr_key_encrypted" TEXT; +ALTER TABLE "users" + ADD COLUMN IF NOT EXISTS "ai_response_timeout_seconds" INTEGER, + ADD COLUMN IF NOT EXISTS "ai_ocr_enabled" BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN IF NOT EXISTS "ai_ocr_provider" TEXT, + ADD COLUMN IF NOT EXISTS "ai_ocr_model" TEXT, + ADD COLUMN IF NOT EXISTS "ai_ocr_base_url" TEXT, + ADD COLUMN IF NOT EXISTS "ai_ocr_key_encrypted" TEXT;