CREATE TABLE IF NOT EXISTS `ai_session` (
`session_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`uuid` TEXT NOT NULL DEFAULT '',
`site_id` INTEGER NOT NULL DEFAULT 0,
`admin_id` INTEGER NOT NULL DEFAULT 0,
`title` TEXT NOT NULL DEFAULT '',
`messages` TEXT NOT NULL DEFAULT '',
`message_count` INTEGER NOT NULL DEFAULT 0,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE UNIQUE INDEX `ai_session_uuid_admin_site` ON `ai_session` (`uuid`, `site_id`, `admin_id`);
CREATE INDEX `ai_session_admin_site_updated` ON `ai_session` (`site_id`, `admin_id`, `updated_at`);
