-- =============================================================================
-- Migration: 2025_10_28_create_transcripts.sql
-- Purpose: Create the table to store AI-generated call transcripts and analysis.
-- =============================================================================

CREATE TABLE IF NOT EXISTS `cloudprime_ai_transcripts` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `tenant_id` int(10) unsigned NOT NULL,
    `call_uuid` varchar(255) NOT NULL,
    `transcript` text NOT NULL,
    `sentiment` varchar(50) DEFAULT NULL COMMENT 'e.g., positive, negative, neutral',
    `lead_name` varchar(255) DEFAULT NULL,
    `lead_contact` varchar(255) DEFAULT NULL,
    `intent` varchar(100) DEFAULT NULL COMMENT 'e.g., sales, support, inquiry',
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `tenant_call` (`tenant_id`, `call_uuid`),
    KEY `tenant_id` (`tenant_id`),
    KEY `call_uuid` (`call_uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;