CREATE TABLE `research_copilot_session` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `user_id` text NOT NULL, `ticker` text NOT NULL, `title` text, `selected_sources` text NOT NULL DEFAULT '["documents","filings","research"]', `pinned_artifact_ids` text NOT NULL DEFAULT '[]', `created_at` text NOT NULL, `updated_at` text NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `research_copilot_session_ticker_uidx` ON `research_copilot_session` (`user_id`,`ticker`); --> statement-breakpoint CREATE INDEX `research_copilot_session_updated_idx` ON `research_copilot_session` (`user_id`,`updated_at`); --> statement-breakpoint CREATE TABLE `research_copilot_message` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `session_id` integer NOT NULL, `user_id` text NOT NULL, `role` text NOT NULL, `content_markdown` text NOT NULL, `citations` text, `follow_ups` text, `suggested_actions` text, `selected_sources` text, `pinned_artifact_ids` text, `memo_section` text, `created_at` text NOT NULL, FOREIGN KEY (`session_id`) REFERENCES `research_copilot_session`(`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 `research_copilot_message_session_idx` ON `research_copilot_message` (`session_id`,`created_at`); --> statement-breakpoint CREATE INDEX `research_copilot_message_user_idx` ON `research_copilot_message` (`user_id`,`created_at`);