Files
hackdex-website/supabase/migrations/20260817235259_patch_download_events.sql
Jared Schoeny 3ac3a9c4b7 Add patch download failure telemetry
Capture actionable diagnostics for signed URL, network, HTTP, and patch application failures while keeping reporting best-effort.
2026-08-18 10:01:15 -06:00

31 lines
1.2 KiB
SQL

-- Patch download telemetry for diagnosing "Failed to fetch" errors from patches.hackdex.app.
-- Inserts are service-role only (no public RLS policies).
create table if not exists public.patch_download_events (
id bigint generated by default as identity primary key,
created_at timestamptz not null default now(),
patch bigint references public.patches(id) on update cascade on delete set null,
hack_slug text,
stage text not null check (stage in ('signed_url', 'fetch', 'patch')),
outcome text not null check (outcome in ('success', 'failure')),
error_name text,
error_message text,
online boolean,
user_agent text,
next_hop_protocol text,
transfer_size bigint,
duration_ms double precision,
timing_entry_present boolean,
probe_same_origin text check (probe_same_origin in ('ok', 'failed', 'timeout', 'skipped')),
probe_patch_host text check (probe_patch_host in ('ok', 'failed', 'timeout', 'skipped')),
country text
);
create index patch_download_events_created_at_idx
on public.patch_download_events (created_at);
create index patch_download_events_outcome_idx
on public.patch_download_events (outcome, created_at);
alter table public.patch_download_events enable row level security;