Files
HealthLog/prisma/migrations/0374_document_thumbnail_failures/migration.sql
T
Marc-André Bombeck 3e08fd0e68 fix(documents): stop queueing a thumbnail that cannot be rendered on every boot
A document whose preview render fails for good (a PDF whose first page
renders blank) was queued by the boot-time backfill, refused, and queued
again at the next boot, without end.

The thumbnail job now keeps the failure with the document
(document_thumbnail_failures, migration 0374): the reason, the attempts
since the last success and when the newest failed. The backfill, both the
boot discovery and the per-account pass, leaves a document out after one
deterministic refusal (raster-failed, empty-render, pixel-cap) or three of
any other kind, until the document changes. A direct enqueue still renders
it, and a preview that is made clears the record.
2026-10-04 15:56:56 +02:00

25 lines
967 B
SQL

-- Why a document has no preview thumbnail. The boot-time backfill skips a
-- document whose render failed for good, until the document changes.
CREATE TABLE "document_thumbnail_failures" (
"document_id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"reason" TEXT NOT NULL,
"attempts" INTEGER NOT NULL DEFAULT 1,
"failed_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "document_thumbnail_failures_pkey" PRIMARY KEY ("document_id")
);
CREATE INDEX "document_thumbnail_failures_user_id_idx"
ON "document_thumbnail_failures"("user_id");
ALTER TABLE "document_thumbnail_failures"
ADD CONSTRAINT "document_thumbnail_failures_document_id_fkey"
FOREIGN KEY ("document_id") REFERENCES "inbound_documents"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "document_thumbnail_failures"
ADD CONSTRAINT "document_thumbnail_failures_user_id_fkey"
FOREIGN KEY ("user_id") REFERENCES "users"("id")
ON DELETE CASCADE ON UPDATE CASCADE;