refactor: replace message.content with message.parts (#868)
This commit is contained in:
parent
553a3d825a
commit
47a630fd53
25 changed files with 1311 additions and 311 deletions
|
|
@ -33,7 +33,9 @@ export const chat = pgTable('Chat', {
|
|||
|
||||
export type Chat = InferSelectModel<typeof chat>;
|
||||
|
||||
export const message = pgTable('Message', {
|
||||
// DEPRECATED: The following schema is deprecated and will be removed in the future.
|
||||
// Read the migration guide at https://github.com/vercel/ai-chatbot/blob/main/docs/04-migrate-to-parts.md
|
||||
export const messageDeprecated = pgTable('Message', {
|
||||
id: uuid('id').primaryKey().notNull().defaultRandom(),
|
||||
chatId: uuid('chatId')
|
||||
.notNull()
|
||||
|
|
@ -43,10 +45,45 @@ export const message = pgTable('Message', {
|
|||
createdAt: timestamp('createdAt').notNull(),
|
||||
});
|
||||
|
||||
export type Message = InferSelectModel<typeof message>;
|
||||
export type MessageDeprecated = InferSelectModel<typeof messageDeprecated>;
|
||||
|
||||
export const message = pgTable('Message_v2', {
|
||||
id: uuid('id').primaryKey().notNull().defaultRandom(),
|
||||
chatId: uuid('chatId')
|
||||
.notNull()
|
||||
.references(() => chat.id),
|
||||
role: varchar('role').notNull(),
|
||||
parts: json('parts').notNull(),
|
||||
attachments: json('attachments').notNull(),
|
||||
createdAt: timestamp('createdAt').notNull(),
|
||||
});
|
||||
|
||||
export type DBMessage = InferSelectModel<typeof message>;
|
||||
|
||||
// DEPRECATED: The following schema is deprecated and will be removed in the future.
|
||||
// Read the migration guide at https://github.com/vercel/ai-chatbot/blob/main/docs/04-migrate-to-parts.md
|
||||
export const voteDeprecated = pgTable(
|
||||
'Vote',
|
||||
{
|
||||
chatId: uuid('chatId')
|
||||
.notNull()
|
||||
.references(() => chat.id),
|
||||
messageId: uuid('messageId')
|
||||
.notNull()
|
||||
.references(() => messageDeprecated.id),
|
||||
isUpvoted: boolean('isUpvoted').notNull(),
|
||||
},
|
||||
(table) => {
|
||||
return {
|
||||
pk: primaryKey({ columns: [table.chatId, table.messageId] }),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export type VoteDeprecated = InferSelectModel<typeof voteDeprecated>;
|
||||
|
||||
export const vote = pgTable(
|
||||
'Vote',
|
||||
'Vote_v2',
|
||||
{
|
||||
chatId: uuid('chatId')
|
||||
.notNull()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue