feat(数据库): 添加提示词优化历史表
- 新增 prompt_optimizations 表存储用户的提示词优化历史 - 支持记录原始提示词、优化后提示词和优化模式 - 添加相应的数据库迁移文件
This commit is contained in:
parent
6e37e61420
commit
fae1dfb7c9
10
src/drizzle/migrations/0009_omniscient_vision.sql
Normal file
10
src/drizzle/migrations/0009_omniscient_vision.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE "prompt_optimizations" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"user_id" varchar(64) NOT NULL,
|
||||
"original_prompt" text NOT NULL,
|
||||
"optimized_prompt" text NOT NULL,
|
||||
"mode" varchar(20) NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "user_settings" ALTER COLUMN "default_model" SET DEFAULT 'claude-sonnet-4-5-20250929';
|
||||
1178
src/drizzle/migrations/meta/0009_snapshot.json
Normal file
1178
src/drizzle/migrations/meta/0009_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,13 @@
|
||||
"when": 1766314954003,
|
||||
"tag": "0008_flat_star_brand",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1766323563111,
|
||||
"tag": "0009_omniscient_vision",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -289,6 +289,23 @@ export const notes = pgTable('notes', {
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow(),
|
||||
});
|
||||
|
||||
// ============================================
|
||||
// 提示词优化历史表
|
||||
// ============================================
|
||||
export const promptOptimizations = pgTable('prompt_optimizations', {
|
||||
id: serial('id').primaryKey(),
|
||||
// 关联用户
|
||||
userId: varchar('user_id', { length: 64 }).notNull(),
|
||||
// 原始提示词
|
||||
originalPrompt: text('original_prompt').notNull(),
|
||||
// 优化后的提示词
|
||||
optimizedPrompt: text('optimized_prompt').notNull(),
|
||||
// 优化模式: concise(简洁版) | detailed(详细版)
|
||||
mode: varchar('mode', { length: 20 }).notNull(),
|
||||
// 时间戳
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
|
||||
});
|
||||
|
||||
// ============================================
|
||||
// 关系定义
|
||||
// ============================================
|
||||
@ -431,3 +448,6 @@ export type NewUserFavoriteAssistant = typeof userFavoriteAssistants.$inferInser
|
||||
|
||||
export type Note = typeof notes.$inferSelect;
|
||||
export type NewNote = typeof notes.$inferInsert;
|
||||
|
||||
export type PromptOptimization = typeof promptOptimizations.$inferSelect;
|
||||
export type NewPromptOptimization = typeof promptOptimizations.$inferInsert;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user