SQL

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
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
id INTEGER Rename | Drop
voice_agent_config_id INTEGER Rename | Drop
room_name TEXT Rename | Drop
call_type TEXT Rename | Drop
caller_phone TEXT Rename | Drop
caller_name TEXT Rename | Drop
caller_email TEXT Rename | Drop
started_at TEXT Rename | Drop
ended_at TEXT Rename | Drop
duration_seconds INTEGER Rename | Drop
conversation_history TEXT Rename | Drop
summary TEXT Rename | Drop
notify_human_count INTEGER Rename | Drop
user_id INTEGER Rename | Drop
latency_metrics TEXT Rename | Drop
agent_mode TEXT Rename | Drop

Foreign Keys

Column Destination
user_id users.id
voice_agent_config_id voice_agent_configs.id

+ Add index

Indexes

Name Columns Unique SQL Drop?
idx_voice_call_history_caller_phone caller_phone SQL
CREATE INDEX idx_voice_call_history_caller_phone
ON voice_call_history(caller_phone)
Drop
idx_voice_call_history_started_at started_at SQL
CREATE INDEX idx_voice_call_history_started_at
ON voice_call_history(started_at)
Drop
idx_voice_call_history_user_id user_id SQL
CREATE INDEX idx_voice_call_history_user_id
ON voice_call_history(user_id)
Drop
idx_voice_call_history_voice_agent_config_id voice_agent_config_id SQL
CREATE INDEX idx_voice_call_history_voice_agent_config_id
ON voice_call_history(voice_agent_config_id)
Drop