-- =====================================================================
-- AI Front Desk Platform — Migration 002
--
-- Bugfix: TransferCallTool and public/webhooks/telnyx.php's buildContext()
-- already referenced $tenant['owner_phone'] and
-- $tenant['emergency_transfer_number'], but neither column existed on the
-- tenants table and fetchTenant() never selected them. Without this,
-- transferCall() would always fail with "No transfer destination
-- configured", for every tenant, always.
-- =====================================================================

SET NAMES utf8mb4;

ALTER TABLE tenants
    ADD COLUMN owner_phone VARCHAR(20) NULL
        COMMENT 'E.164 number to ring for general human handoff'
        AFTER timezone,
    ADD COLUMN emergency_transfer_number VARCHAR(20) NULL
        COMMENT 'E.164 number to ring for emergency/urgent transfers; falls back to owner_phone if null'
        AFTER owner_phone;
