ALTER TABLE asterisk_call_links ADD COLUMN IF NOT EXISTS voice_start_language TEXT NULL;
ALTER TABLE asterisk_call_links ADD COLUMN IF NOT EXISTS customer_name_status TEXT NULL;
ALTER TABLE asterisk_call_links ADD COLUMN IF NOT EXISTS customer_name_value TEXT NULL;
ALTER TABLE asterisk_call_links ADD COLUMN IF NOT EXISTS customer_name_source TEXT NULL;
ALTER TABLE asterisk_call_links ADD COLUMN IF NOT EXISTS customer_name_resolved_at TEXT NULL;

CREATE INDEX IF NOT EXISTS idx_asterisk_call_links_voice_start_language
ON asterisk_call_links(voice_start_language);
CREATE INDEX IF NOT EXISTS idx_asterisk_call_links_customer_name_status
ON asterisk_call_links(customer_name_status);
CREATE INDEX IF NOT EXISTS idx_asterisk_call_links_customer_name_source
ON asterisk_call_links(customer_name_source);
CREATE INDEX IF NOT EXISTS idx_asterisk_call_links_customer_name_resolved_at
ON asterisk_call_links(customer_name_resolved_at);

ALTER TABLE voice_ai_sessions ADD COLUMN IF NOT EXISTS voice_start_language TEXT NULL;
ALTER TABLE voice_ai_sessions ADD COLUMN IF NOT EXISTS customer_name_status TEXT NULL;
ALTER TABLE voice_ai_sessions ADD COLUMN IF NOT EXISTS customer_name_value TEXT NULL;
ALTER TABLE voice_ai_sessions ADD COLUMN IF NOT EXISTS customer_name_source TEXT NULL;
ALTER TABLE voice_ai_sessions ADD COLUMN IF NOT EXISTS customer_name_resolved_at TEXT NULL;

CREATE INDEX IF NOT EXISTS idx_voice_ai_sessions_voice_start_language
ON voice_ai_sessions(voice_start_language);
CREATE INDEX IF NOT EXISTS idx_voice_ai_sessions_customer_name_status
ON voice_ai_sessions(customer_name_status);
CREATE INDEX IF NOT EXISTS idx_voice_ai_sessions_customer_name_source
ON voice_ai_sessions(customer_name_source);
CREATE INDEX IF NOT EXISTS idx_voice_ai_sessions_customer_name_resolved_at
ON voice_ai_sessions(customer_name_resolved_at);
