-- Migration 184: Add optional relation to existing global contacts on location contacts
-- Date: 2026-02-18
-- Purpose: Allow location contact rows to reference contacts.id for explicit linkage

ALTER TABLE locations_contacts
ADD COLUMN IF NOT EXISTS related_contact_id INTEGER REFERENCES contacts(id) ON DELETE SET NULL;

CREATE INDEX IF NOT EXISTS idx_locations_contacts_related_contact_id
ON locations_contacts(related_contact_id);
