Haewon Kam
7fe3ff82c9
feat: DB V3 dual-write — clinics + analysis_runs + channel_snapshots
Phase 2-4 of SaaS schema migration. All Edge Functions now write to
BOTH legacy marketing_reports AND new V3 tables:
discover-channels:
- UPSERT clinics (url-based dedup)
- INSERT analysis_runs (status: discovering)
collect-channel-data:
- INSERT channel_snapshots (one per channel — time-series!)
- INSERT screenshots (evidence rows)
- UPDATE analysis_runs (raw_channel_data, vision_analysis)
generate-report:
- UPDATE analysis_runs (report, status: complete)
- UPDATE clinics (last_analyzed_at, established_year)
Frontend passes clinicId + runId through all 3 phases.
Legacy marketing_reports still written for backward compatibility.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>