-- Migration 030: Add jira_issue_key to sessions for Jira Cloud linking (CF-762)
-- Links sessions to Jira issues after task management moved to Jira Cloud

ALTER TABLE sessions ADD COLUMN IF NOT EXISTS jira_issue_key TEXT;

CREATE INDEX IF NOT EXISTS idx_sessions_jira_issue_key ON sessions (jira_issue_key) WHERE jira_issue_key IS NOT NULL;

-- Also add to task_activity for historical audit trail linking
ALTER TABLE task_activity ADD COLUMN IF NOT EXISTS jira_issue_key TEXT;
