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;