-- ai 0003: agent_sessions -- Generated by termix-plugin migrations. Review before committing. CREATE TABLE IF NOT EXISTS `p_ai_agent_sessions` ( `id` int AUTO_INCREMENT PRIMARY KEY, `session_id` varchar(36) NOT NULL UNIQUE, `user_id` varchar(255) NOT NULL, `host_id` int NOT NULL, `provider_id` int NOT NULL, `agent` varchar(32) NOT NULL, `model` text NOT NULL, `cwd` text NOT NULL, `executable` text NOT NULL, `native_id` text, `title` text, `archived` boolean NOT NULL DEFAULT false, `queue_paused` boolean NOT NULL DEFAULT false, `draft` text, `attachments` text NOT NULL DEFAULT ('[]'), `updated_at` text NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ); CREATE INDEX `idx_ai_agent_sessions_user` ON `p_ai_agent_sessions` (`user_id`); CREATE TABLE IF NOT EXISTS `p_ai_agent_events` ( `id` int AUTO_INCREMENT PRIMARY KEY, `session_id` varchar(36) NOT NULL, `user_id` varchar(255) NOT NULL, `seq` int NOT NULL, `kind` varchar(16) NOT NULL, `text` text NOT NULL, `request_id` text, `choices` text, FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ); CREATE UNIQUE INDEX `idx_ai_agent_events_session_seq` ON `p_ai_agent_events` (`session_id`, `seq`); CREATE TABLE IF NOT EXISTS `p_ai_agent_queue` ( `id` int AUTO_INCREMENT PRIMARY KEY, `session_id` varchar(36) NOT NULL, `user_id` varchar(255) NOT NULL, `prompt_id` varchar(36) NOT NULL, `position` int NOT NULL, `text` text NOT NULL, `attachment_ids` text NOT NULL DEFAULT ('[]'), FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ); CREATE INDEX `idx_ai_agent_queue_session` ON `p_ai_agent_queue` (`session_id`, `position`);