-- Migration 026: Add assigned_user_id to leads table for team collaboration.
-- Allows leads to be assigned to individual org members.

ALTER TABLE leads
    ADD COLUMN assigned_user_id BIGINT UNSIGNED NULL DEFAULT NULL
        COMMENT 'FK -> users.id; NULL = unassigned'
        AFTER org_id,
    ADD KEY idx_lead_assigned (assigned_user_id),
    ADD CONSTRAINT fk_lead_assigned FOREIGN KEY (assigned_user_id)
        REFERENCES users(id) ON DELETE SET NULL;
