From afef9b298fee65de0e8fe27da5aa1d605d9f4002 Mon Sep 17 00:00:00 2001 From: Schalli Date: Wed, 8 Jul 2026 09:16:15 +0200 Subject: [PATCH] fix(db): add missing FavoriteLink migration FavoriteLink existed in schema.prisma but was never captured in a migration -- same bug class as the DashboardLayout fix in 20260629130000_add_missing_tables. It silently worked in local dev (table created via db push) but any environment relying on `prisma migrate deploy` never got the table, causing every GET /favorites request to 500 with PrismaClientKnownRequestError P2021 ("table does not exist"). Found live testing the production deploy at alpha.tessera.ctl.de: adding a Favoriten widget triggered the 500. Confirmed via server logs (docker logs) and by inspecting _prisma_migrations / \dt on that database. CREATE TABLE/INDEX IF NOT EXISTS makes this safe to apply against environments where the table already exists untracked (verified: ran clean against local dev's DB, which already had the table from a prior db push, with zero errors and zero data loss). Co-Authored-By: Claude Sonnet 5 --- .../migration.sql | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 apps/api/prisma/migrations/20260708090000_add_favorite_link/migration.sql diff --git a/apps/api/prisma/migrations/20260708090000_add_favorite_link/migration.sql b/apps/api/prisma/migrations/20260708090000_add_favorite_link/migration.sql new file mode 100644 index 0000000..38e5bfb --- /dev/null +++ b/apps/api/prisma/migrations/20260708090000_add_favorite_link/migration.sql @@ -0,0 +1,29 @@ +-- CreateTable +-- FavoriteLink existed in schema.prisma but was never captured in a migration +-- (created via db push in local dev, same class of bug as the DashboardLayout +-- fix in 20260629130000_add_missing_tables). IF NOT EXISTS makes this safe to +-- apply against environments where the table already exists untracked. +CREATE TABLE IF NOT EXISTS "FavoriteLink" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "tenantId" TEXT NOT NULL, + "widgetId" TEXT NOT NULL, + "title" TEXT NOT NULL, + "url" TEXT NOT NULL, + "iconUrl" TEXT, + "position" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "FavoriteLink_pkey" PRIMARY KEY ("id"), + CONSTRAINT "FavoriteLink_widgetId_fkey" FOREIGN KEY ("widgetId") REFERENCES "WidgetInstance"("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateIndex +CREATE INDEX IF NOT EXISTS "FavoriteLink_userId_idx" ON "FavoriteLink"("userId"); + +-- CreateIndex +CREATE INDEX IF NOT EXISTS "FavoriteLink_tenantId_idx" ON "FavoriteLink"("tenantId"); + +-- CreateIndex +CREATE INDEX IF NOT EXISTS "FavoriteLink_widgetId_idx" ON "FavoriteLink"("widgetId");