CREATE TABLE IF NOT EXISTS `whatsapp_contact_intakes` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `phone` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `customer_id` bigint(20) DEFAULT NULL,
  `intake_type` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
  `source_message` text COLLATE utf8mb4_unicode_ci,
  `normalized_text` text COLLATE utf8mb4_unicode_ci,
  `payload_json` mediumtext COLLATE utf8mb4_unicode_ci,
  `human_required` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_wci_phone_created` (`phone`,`created_at`),
  KEY `idx_wci_customer` (`customer_id`),
  KEY `idx_wci_type_status` (`intake_type`,`status`),
  KEY `idx_wci_human_created` (`human_required`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
