-- Add WhatsApp campaign support to campaigns table
ALTER TABLE campaigns ADD COLUMN IF NOT EXISTS whatsapp_session_id varchar(255);
ALTER TABLE campaigns ADD COLUMN IF NOT EXISTS campaign_type varchar(20) DEFAULT 'voice';

-- Add index for WhatsApp campaigns
CREATE INDEX IF NOT EXISTS campaigns_whatsapp_session_id_idx ON campaigns(whatsapp_session_id);
CREATE INDEX IF NOT EXISTS campaigns_campaign_type_idx ON campaigns(campaign_type);

-- Add flow execution reference to whatsapp_chats for campaign tracking
ALTER TABLE whatsapp_chats ADD COLUMN IF NOT EXISTS campaign_id varchar(36);
ALTER TABLE whatsapp_chats ADD COLUMN IF NOT EXISTS flow_execution_id varchar(36);
CREATE INDEX IF NOT EXISTS idx_ws_chats_campaign_id ON whatsapp_chats(campaign_id);
