-- events 도메인 PR-1 (7/11) — partial unique on (source, source_ref)
-- 외부 source dedup (이메일 Message-ID, git commit hash, webhook event_id 등).
-- PR-1 에서는 schema 만 박고 dedup 동작 검증은 PR-4 MailPlus ingest 시.

CREATE UNIQUE INDEX IF NOT EXISTS events_source_ref_uq
    ON events (source, source_ref)
    WHERE source_ref IS NOT NULL;
