Files
gstack/supabase/migrations/002_community_tier.sql
Garry Tan 1584deaca8 feat: richer error telemetry — error_message + failed_step fields
Adds error_message (max 200 chars, e.g. "bun test: 3 tests failed")
and failed_step (e.g. "run_tests", "create_pr") to telemetry events.
Schema, ingest function, and local logger all updated. Makes crash
reports actionable instead of just "timeout — 252 occurrences".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 08:20:44 -07:00

44 lines
1.8 KiB
SQL

-- gstack community tier schema
-- Adds authenticated backup, benchmarks, email, and richer error telemetry.
-- Add error context columns to telemetry_events
ALTER TABLE telemetry_events ADD COLUMN error_message TEXT;
ALTER TABLE telemetry_events ADD COLUMN failed_step TEXT;
-- Add columns to installations for backup + email + auth identity
ALTER TABLE installations ADD COLUMN user_id UUID;
ALTER TABLE installations ADD COLUMN email TEXT;
ALTER TABLE installations ADD COLUMN config_snapshot JSONB;
ALTER TABLE installations ADD COLUMN analytics_snapshot JSONB;
ALTER TABLE installations ADD COLUMN retro_history JSONB;
ALTER TABLE installations ADD COLUMN last_backup_at TIMESTAMPTZ;
ALTER TABLE installations ADD COLUMN backup_version INTEGER DEFAULT 0;
-- RLS: authenticated users can read/write their own installation row
CREATE POLICY "auth_read_own" ON installations
FOR SELECT USING (
(select auth.uid()) IS NOT NULL AND user_id = (select auth.uid())
);
CREATE POLICY "auth_write_own" ON installations
FOR INSERT WITH CHECK (user_id = (select auth.uid()));
CREATE POLICY "auth_update_own" ON installations
FOR UPDATE USING (user_id = (select auth.uid()))
WITH CHECK (user_id = (select auth.uid()));
-- Community benchmarks (computed by edge function, cached)
CREATE TABLE community_benchmarks (
skill TEXT PRIMARY KEY,
median_duration_s NUMERIC,
p25_duration_s NUMERIC,
p75_duration_s NUMERIC,
total_runs BIGINT,
success_rate NUMERIC,
updated_at TIMESTAMPTZ DEFAULT now()
);
ALTER TABLE community_benchmarks ENABLE ROW LEVEL SECURITY;
CREATE POLICY "anon_select" ON community_benchmarks FOR SELECT USING (true);
CREATE POLICY "service_upsert" ON community_benchmarks FOR ALL
USING ((select auth.role()) = 'service_role')
WITH CHECK ((select auth.role()) = 'service_role');