From 7a79b52baff52bd100aa939f98fbfc703afeced6 Mon Sep 17 00:00:00 2001 From: xCyanGrizzly Date: Fri, 22 May 2026 23:07:40 +0200 Subject: [PATCH] feat(db): add attemptCount on SkippedPackage + CHANNEL_ACCESS_LOST enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit attemptCount tracks how many times the worker has tried each failed source message. Combined with WORKER_MAX_SKIP_ATTEMPTS (default 5), the worker will auto-retry across cycles but eventually let the watermark advance past a chronically failing file so cycles aren't pinned forever. The SkippedPackage row stays so the user can manually retry via the UI. CHANNEL_ACCESS_LOST is a new notification type the worker emits when a source channel becomes inaccessible (account got removed, channel deleted, etc.) — surfaces the issue instead of silently failing every cycle as we've been doing with "Iridium 2 w/ Add-ons [Completed]". Co-Authored-By: Claude Opus 4.7 (1M context) --- .../migration.sql | 8 ++++++++ prisma/schema.prisma | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 prisma/migrations/20260522000000_skip_attempt_count_and_channel_access/migration.sql diff --git a/prisma/migrations/20260522000000_skip_attempt_count_and_channel_access/migration.sql b/prisma/migrations/20260522000000_skip_attempt_count_and_channel_access/migration.sql new file mode 100644 index 0000000..44e9bf9 --- /dev/null +++ b/prisma/migrations/20260522000000_skip_attempt_count_and_channel_access/migration.sql @@ -0,0 +1,8 @@ +-- AlterTable: track how many times the worker has tried each skipped source message. +-- Existing rows default to 1 (they represent a single past attempt that the worker +-- chose to record). Future failures increment via upsertSkippedPackage. +ALTER TABLE "skipped_packages" ADD COLUMN "attemptCount" INTEGER NOT NULL DEFAULT 1; + +-- AlterEnum: add CHANNEL_ACCESS_LOST so the worker can surface a notification +-- when a source channel becomes inaccessible (account removed, channel deleted, etc.) +ALTER TYPE "NotificationType" ADD VALUE 'CHANNEL_ACCESS_LOST'; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c9646d1..9fd2eca 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -741,6 +741,12 @@ model SkippedPackage { sourceTopicId BigInt? isMultipart Boolean @default(false) partCount Int @default(1) + /// How many times the worker has tried to process this source message. + /// The worker auto-retries failures across cycles up to a configurable cap + /// (WORKER_MAX_SKIP_ATTEMPTS, default 5). After the cap, the watermark is + /// allowed to advance past the failure so cycles aren't pinned forever; + /// the user can manually retry via the UI to reset and try again. + attemptCount Int @default(1) accountId String account TelegramAccount @relation(fields: [accountId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) @@ -830,6 +836,7 @@ enum NotificationType { DOWNLOAD_FAILED GROUPING_CONFLICT INTEGRITY_AUDIT + CHANNEL_ACCESS_LOST } enum NotificationSeverity {