diff --git a/db/schema.sql b/db/schema.sql index b87638a..1a477ae 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -479,3 +479,58 @@ CREATE TABLE IF NOT EXISTS `guardian_events` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- Dump completed on 2026-06-29 23:15:44 + +CREATE TABLE IF NOT EXISTS `email_triage` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `msg_id` varchar(255) NOT NULL, + `account` varchar(64) NOT NULL DEFAULT 'gmail', + `from_name` varchar(255) DEFAULT NULL, + `from_email` varchar(255) DEFAULT NULL, + `subject` varchar(500) DEFAULT NULL, + `date_received` datetime DEFAULT NULL, + `category` varchar(32) NOT NULL DEFAULT 'info', + `priority` int(11) NOT NULL DEFAULT 3, + `summary` text DEFAULT NULL, + `draft_reply` text DEFAULT NULL, + `action_taken` varchar(32) NOT NULL DEFAULT 'none', + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `uq_msg` (`msg_id`), + KEY `idx_category` (`category`), + KEY `idx_action` (`action_taken`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `email_actions` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `msg_id` varchar(255) DEFAULT NULL, + `from_name` varchar(255) DEFAULT NULL, + `from_email` varchar(255) DEFAULT NULL, + `subject` varchar(500) DEFAULT NULL, + `received_at` datetime DEFAULT NULL, + `suggested_title` varchar(255) DEFAULT NULL, + `suggested_date` date DEFAULT NULL, + `task_id` int(11) DEFAULT NULL, + `appointment_id` int(11) DEFAULT NULL, + `dismissed` tinyint(1) NOT NULL DEFAULT 0, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_dismissed` (`dismissed`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `email_sent` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `account` varchar(64) NOT NULL DEFAULT 'gmail', + `to_email` varchar(255) NOT NULL, + `to_name` varchar(255) DEFAULT NULL, + `subject` varchar(500) DEFAULT NULL, + `body` text DEFAULT NULL, + `triage_id` int(11) DEFAULT NULL, + `status` varchar(32) NOT NULL DEFAULT 'sent', + `sent_at` timestamp NULL DEFAULT current_timestamp(), + `error` text DEFAULT NULL, + `message_id` varchar(255) DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `idx_account` (`account`), + KEY `idx_status` (`status`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;