25 lines
951 B
SQL
25 lines
951 B
SQL
CREATE TABLE `conversations` (
|
|
`created_at` text NOT NULL,
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`model_id` text NOT NULL,
|
|
`project_id` text NOT NULL,
|
|
`title` text DEFAULT '新会话' NOT NULL,
|
|
`updated_at` text NOT NULL,
|
|
FOREIGN KEY (`model_id`) REFERENCES `models`(`id`) ON UPDATE no action ON DELETE no action,
|
|
FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `conversations_project_id_idx` ON `conversations` (`project_id`);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `messages` (
|
|
`content` text DEFAULT '' NOT NULL,
|
|
`conversation_id` text NOT NULL,
|
|
`created_at` text NOT NULL,
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`parts` text,
|
|
`role` text NOT NULL,
|
|
FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `messages_conversation_id_idx` ON `messages` (`conversation_id`);
|