Spaces:
Sleeping
Sleeping
Download backend/sql/028_error_reports.sql from stylevoice/talk: direct link, hf CLI and curl.
- Browser
- Download file 3.3 kB
-
https://huggingface.co/spaces/stylevoice/talk/resolve/main/backend/sql/028_error_reports.sql
- Command line
-
hf download hf://spaces/stylevoice/talk/backend/sql/028_error_reports.sql
-
curl -L -o 028_error_reports.sql https://huggingface.co/spaces/stylevoice/talk/resolve/main/backend/sql/028_error_reports.sql
3.3 kB
| -- ์ฌ์ฉ์ ์ค๋ฅ ์ ๊ณ (์ด์ ๋ชจ๋ ๋ฑ์์ "์ค๋ฅ ์ ๊ณ ํ๊ธฐ" ๋ฒํผ) | |
| -- | |
| -- ํ๋ฉด ์คํฌ๋ฆฐ์ท + ๊ตฌ์กฐํ ๋ก๊ทธ (DrivingTimingProvider.turnLogs / SttPlugin ์ด๋ฒคํธ ๋ฑ) + | |
| -- ๋๋ฐ์ด์ค ์ปจํ ์คํธ (platform / version / route) ๋ฅผ ๋ฐ์ ๋ณด๊ด. admin /ad โ "์ค๋ฅ ์ ๊ณ " | |
| -- ํญ์์ ๋ชฉ๋ก/์์ธ ํ์ธ ๊ฐ๋ฅ. | |
| -- | |
| -- Storage: ์คํฌ๋ฆฐ์ท์ ๊ธฐ์กด `scheduled-audio` bucket ์ `error-reports/<user_id>/<report_id>.png` | |
| -- ๊ฒฝ๋ก ์ฌ์ฌ์ฉ (๋ณ๋ bucket ์ ๋ง๋ค๊ณ ๋จ์ํ). | |
| CREATE TABLE IF NOT EXISTS public.error_reports ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE, | |
| -- ์ฌ์ฉ์ ์ ๋ ฅ | |
| route TEXT NOT NULL, -- '/driving', '/message' ๋ฑ (์๋ ์บก์ฒ) | |
| description TEXT, -- ์ ํ โ ์ฌ์ฉ์๊ฐ ์ ๋ ฅํ ํ ์ค ๋ฉ๋ชจ | |
| -- ์๋ ์ฒจ๋ถ | |
| screenshot_path TEXT, -- storage path (signed URL ์ผ๋ก admin ํ์) | |
| screenshot_url TEXT, -- signed URL (1๋ ) | |
| logs JSONB, -- ๊ตฌ์กฐํ ๋ก๊ทธ (turnLogs, events ๋ฑ) | |
| context JSONB, -- ๋๋ฐ์ด์ค/ํ๋ซํผ ์ ๋ณด | |
| -- admin ์ฒ๋ฆฌ ์ํ | |
| handled BOOLEAN NOT NULL DEFAULT FALSE, | |
| handled_at TIMESTAMPTZ, | |
| admin_note TEXT, -- admin ๋ฉ๋ชจ (ํด๊ฒฐ์ฑ / ๋ถ๋ฅ) | |
| created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | |
| updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() | |
| ); | |
| CREATE INDEX IF NOT EXISTS idx_error_reports_created | |
| ON public.error_reports (created_at DESC); | |
| CREATE INDEX IF NOT EXISTS idx_error_reports_unhandled | |
| ON public.error_reports (created_at DESC) | |
| WHERE handled = FALSE; | |
| ALTER TABLE public.error_reports ENABLE ROW LEVEL SECURITY; | |
| -- ์ฌ์ฉ์: ๋ณธ์ธ ์ ๊ณ ๋ง INSERT | |
| DROP POLICY IF EXISTS error_reports_insert ON public.error_reports; | |
| CREATE POLICY error_reports_insert ON public.error_reports | |
| FOR INSERT | |
| WITH CHECK (user_id = auth.uid()); | |
| -- ์ฌ์ฉ์: ๋ณธ์ธ ์ ๊ณ ๋ง SELECT (์๊ธฐ ์ ๊ณ ๋ชฉ๋ก ํ์ธ์ฉ, ํฅํ ์ฌ์ฉ) | |
| DROP POLICY IF EXISTS error_reports_select_own ON public.error_reports; | |
| CREATE POLICY error_reports_select_own ON public.error_reports | |
| FOR SELECT | |
| USING (user_id = auth.uid()); | |
| -- admin (service_role ์ฌ์ฉ) ์ RLS bypass โ ๋ชจ๋ ์ ๊ณ ์กฐํ/๊ฐฑ์ ๊ฐ๋ฅ. | |
| CREATE OR REPLACE FUNCTION public._error_reports_touch_updated_at() | |
| RETURNS TRIGGER AS $$ | |
| BEGIN | |
| NEW.updated_at = NOW(); | |
| RETURN NEW; | |
| END; | |
| $$ LANGUAGE plpgsql; | |
| DROP TRIGGER IF EXISTS error_reports_touch_updated_at ON public.error_reports; | |
| CREATE TRIGGER error_reports_touch_updated_at | |
| BEFORE UPDATE ON public.error_reports | |
| FOR EACH ROW EXECUTE FUNCTION public._error_reports_touch_updated_at(); | |
| COMMENT ON TABLE public.error_reports IS | |
| '์ฌ์ฉ์ ์ค๋ฅ ์ ๊ณ โ ํ๋ฉด ์คํฌ๋ฆฐ์ท + ๋ก๊ทธ + ๋๋ฐ์ด์ค ์ปจํ ์คํธ.'; | |
| COMMENT ON COLUMN public.error_reports.logs IS | |
| '๊ตฌ์กฐํ ๋ก๊ทธ. ์ด์ ๋ชจ๋: {"turn_logs": [...], "events": [...]}.'; | |
| COMMENT ON COLUMN public.error_reports.context IS | |
| '๋๋ฐ์ด์ค ์ปจํ ์คํธ: {"platform": "ios", "version": "26.4", "app_version": "...", "user_agent": "..."}.'; | |