-- ════════════════════════════════════════════════════════════════════════ -- 익명(anon) 키로 테이블을 읽고 쓰던 RLS 정책 정리 · 2026-10-07 -- -- 확인한 사실 (2026-10-07, anon 키로 행 수만 조회): -- marketing_reports 103 · clinics 12 · analysis_runs 53 · channel_snapshots 189 · screenshots 112 -- content_plans 6 · supporter_builds 3 · supporter_inputs 2 행이 anon 키로 읽혔다. -- anon 키는 webforai.kr 번들(2026-10-07 c2e7d5a 로 제거)과 infinith-demo 번들에 공개로 들어 있었다. -- -- 선행 조건 (2026-10-07 완료): -- infinith-demo 화면의 조회·쓰기를 서버 함수 api/db.js(service role)로 옮겼다. -- 워커(workers/supporters-build), Edge Function, scripts/* 는 service role 키를 쓴다. 이 SQL 의 영향을 받지 않는다. -- -- 되돌리기: 각 정책을 아래 주석의 마이그레이션 파일에 있는 CREATE POLICY 문으로 다시 만든다. -- ════════════════════════════════════════════════════════════════════════ begin; -- 20260330_create_tables.sql drop policy if exists "anon_read_reports" on public.marketing_reports; -- 20260405_saas_schema_v3.sql drop policy if exists "anon_read_clinics" on public.clinics; drop policy if exists "anon_read_runs" on public.analysis_runs; drop policy if exists "anon_read_snapshots" on public.channel_snapshots; drop policy if exists "anon_read_screenshots" on public.screenshots; drop policy if exists "anon_read_plans" on public.content_plans; drop policy if exists "anon_read_performance" on public.performance_metrics; drop policy if exists "anon_read_content_perf" on public.content_performance; drop policy if exists "anon_read_adjustments" on public.strategy_adjustments; -- 20260406_clinic_registry.sql drop policy if exists "public_read_registry" on public.clinic_registry; -- 20260907_supporter_builds.sql drop policy if exists "anon can read builds" on public.supporter_builds; drop policy if exists "anon can read inputs" on public.supporter_inputs; drop policy if exists "anon can insert inputs" on public.supporter_inputs; -- 20260907_supporter_builds_queue.sql (익명 빌드 큐 등록: 등록되면 워커가 빌드·배포를 시작한다) drop policy if exists "anon can queue builds" on public.supporter_builds; -- 20260831_discovery_leads.sql (예전 진단 신청 폼. 지금은 쓰는 코드가 없다) drop policy if exists "anon can insert discovery leads" on public.discovery_leads; -- 스토리지 버킷의 공개 읽기(20260407_screenshots_storage.sql "public_read_screenshots")는 -- 병원 채널 스크린샷 이미지다. 버킷 공개 여부와 함께 별도로 결정한다. commit;