CREATE TABLE `chat_session` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `workspace_id` integer NOT NULL, `user_id` integer NOT NULL, `title` text NOT NULL, `messages` text NOT NULL, `created_at` integer NOT NULL, `updated_at` integer NOT NULL, FOREIGN KEY (`workspace_id`) REFERENCES `workspace`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `chat_session_workspace_user_updated_idx` ON `chat_session` (`workspace_id`,`user_id`,`updated_at`);