From 689500c85e3071bc1e2558f14c1d64c65bda8451 Mon Sep 17 00:00:00 2001 From: Mathias Date: Wed, 3 Jun 2026 22:45:12 +0200 Subject: [PATCH] =?UTF-8?q?feat(store):=20migration=20007=20=E2=80=94=20pe?= =?UTF-8?q?r-video=20transcript=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds videos.transcript_status (NULL|none|fetched|rate_limited) and videos.rate_limited_at, so the runner can record a 429 and skip re-fetching a still-throttled video until a backoff window elapses. Columns inherit the existing videos RLS policy (migration 003); no policy change needed. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../migrations/007_transcript_status.down.sql | 2 ++ .../migrations/007_transcript_status.up.sql | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 internal/adapters/store/migrations/007_transcript_status.down.sql create mode 100644 internal/adapters/store/migrations/007_transcript_status.up.sql diff --git a/internal/adapters/store/migrations/007_transcript_status.down.sql b/internal/adapters/store/migrations/007_transcript_status.down.sql new file mode 100644 index 0000000..325b4c9 --- /dev/null +++ b/internal/adapters/store/migrations/007_transcript_status.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE videos DROP COLUMN IF EXISTS rate_limited_at; +ALTER TABLE videos DROP COLUMN IF EXISTS transcript_status; diff --git a/internal/adapters/store/migrations/007_transcript_status.up.sql b/internal/adapters/store/migrations/007_transcript_status.up.sql new file mode 100644 index 0000000..ec455a2 --- /dev/null +++ b/internal/adapters/store/migrations/007_transcript_status.up.sql @@ -0,0 +1,17 @@ +-- Migration 007: per-video transcript fetch status, for rate-limit backoff. +-- +-- transcript_status records the outcome of the last transcript attempt: +-- NULL = not yet attempted +-- 'none' = checked, no usable transcript (permanent — SourceNone) +-- 'fetched' = transcript resolved and summarized (summary_id not null) +-- 'rate_limited'= the caption endpoint returned 429; retry after a backoff window +-- +-- rate_limited_at stamps WHEN the 429 was seen, so the runner can skip re-fetching +-- a still-throttled video until NOW() - rate_limited_at exceeds TAPIR_FETCH_BACKOFF. +-- It is cleared (set NULL) whenever the status moves off 'rate_limited'. +-- +-- No RLS policy changes needed: videos already has ENABLE + FORCE ROW LEVEL +-- SECURITY (migration 003) with the videos_isolation policy. New columns inherit +-- that protection automatically. +ALTER TABLE videos ADD COLUMN transcript_status TEXT; +ALTER TABLE videos ADD COLUMN rate_limited_at TIMESTAMPTZ;