docs: 익명 키 정책 정리 SQL 을 쓰기 정책까지 포함한 실행본으로 바꾼다

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 5.5 committed 2026-10-07 16:12:34 +09:00
1 parent 0be730f0f9
commit 0d1fdd3430
3 files changed
+18 -13

No files matched your search

@@ -1,18 +1,16 @@
-- ════════════════════════════════════════════════════════════════════════
-- 초안 (실행하지 않음) · 2026-10-07
-- 익명(anon) 키로 실제 병원 데이터를 읽을 수 있는 RLS 정책 정리
-- 익명(anon) 키로 테이블을 읽고 쓰던 RLS 정책 정리 · 2026-10-07
--
-- 확인한 사실 (2026-10-07, anon 키로 행 수만 조회):
-- marketing_reports 103 · clinics 12 · channel_snapshots 189 · analysis_runs 53
-- supporter_builds 3 · supporter_inputs 2 행이 anon 키로 읽힌다.
-- anon 키는 infinith-demo 번들에 공개로 들어 있다 (webforai.kr 번들에서는 2026-10-07 c2e7d5a 로 제거).
-- 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 번들에 공개로 들어 있었다.
--
-- 실행 전 확인할 것 (haewon 결정 필요):
-- 1. infinith-demo 의 리포트·플랜·스튜디오·병원 확인 화면(/report, /plan, /clinic, /supporters, /build)은
-- anon 키로 이 테이블을 읽는다. 아래를 실행하면 그 화면들이 빈 화면이 된다.
-- 대안: 로그인(Supabase Auth) 도입 후 authenticated 로 바꾸거나, 읽기를 Edge Function(service role) 뒤로 옮긴다.
-- 2. 운영 DB 변경이다. 실행 전에 영향 범위를 확인받고, Supabase 대시보드 SQL 편집기에서 실행한다.
-- 3. 되돌리기: 각 정책을 원래 마이그레이션의 CREATE POLICY 문으로 다시 만들면 된다 (파일명은 아래 주석).
-- 선행 조건 (2026-10-07 완료):
-- infinith-demo 화면의 조회·쓰기를 서버 함수 api/db.js(service role)로 옮겼다.
-- 워커(workers/supporters-build), Edge Function, scripts/* 는 service role 키를 쓴다. 이 SQL 의 영향을 받지 않는다.
--
-- 되돌리기: 각 정책을 아래 주석의 마이그레이션 파일에 있는 CREATE POLICY 문으로 다시 만든다.
-- ════════════════════════════════════════════════════════════════════════
begin;
@@ -36,6 +34,13 @@ 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")는
-- 병원 채널 스크린샷 이미지다. 버킷 공개 여부와 함께 별도로 결정한다.