-- TaskBit AI Scans table
CREATE TABLE IF NOT EXISTS `ai_scans` (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_id` varchar(250) DEFAULT NULL,
  `image_path` varchar(500) DEFAULT NULL,
  `ai_model` varchar(100) DEFAULT NULL,
  `ai_provider` varchar(50) DEFAULT NULL,
  `prompt_tokens` int DEFAULT 0,
  `completion_tokens` int DEFAULT 0,
  `total_tokens` int DEFAULT 0,
  `cost_usd` decimal(10,6) DEFAULT 0,
  `tasks_extracted` text DEFAULT NULL COMMENT 'JSON array of extracted tasks',
  `tasks_count` int DEFAULT 0,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_device_id` (`device_id`),
  KEY `idx_created_at` (`created_at`),
  KEY `idx_ai_model` (`ai_model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
