CREATE TABLE voice_call_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
voice_agent_config_id INTEGER NOT NULL,
room_name TEXT NOT NULL,
call_type TEXT NOT NULL,
-- 'inbound' or 'outbound'
caller_phone TEXT,
caller_name TEXT,
caller_email TEXT,
started_at TEXT NOT NULL,
ended_at TEXT,
duration_seconds INTEGER,
conversation_history TEXT,
-- JSON array of messages
summary TEXT,
notify_human_count INTEGER DEFAULT 0,
-- Number of times notify_human was called
user_id INTEGER,
latency_metrics TEXT,
agent_mode TEXT,
FOREIGN KEY (voice_agent_config_id) REFERENCES voice_agent_configs(id) ON DELETE SET NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
)