-- Grid/contacts unification — explicit link from a fundraising-grid contact
-- "pill" to its row in the contacts table.
--
-- ADDITIVE + REVERSIBLE (CLAUDE.md guardrail #3): adds one nullable column.
-- Until now a grid contact was tied to its contact only by name/email matching,
-- which drifted and produced the people double-count. fundraising_contacts.contact_id
-- records the real link (populated by sync_fundraising_relational, which already
-- upserts the contact and now stores its id). entity_resolution prefers this link
-- over heuristic matching.
--
-- contact_id is a LOGICAL foreign key to contacts(id). It is intentionally NOT a
-- declared SQLite FOREIGN KEY: contacts are soft-deleted (never hard-deleted), so
-- there is nothing to cascade, and SQLite's ALTER TABLE ADD COLUMN cannot add an
-- enforced FK cleanly. Nullable so existing rows are valid until backfilled.
ALTER TABLE fundraising_contacts ADD COLUMN contact_id TEXT;

CREATE INDEX IF NOT EXISTS idx_fundraising_contacts_contact ON fundraising_contacts(contact_id);
