Skip to content

Commit 62960eb

Browse files
committed
idはincrementでないほうがよい説 (しらんけど)
1 parent 44aca80 commit 62960eb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

app/lib/chatHistory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ export async function getChat(docsId: string) {
5050
include: {
5151
messages: {
5252
orderBy: {
53-
id: "asc",
53+
createdAt: "asc",
5454
},
5555
},
5656
},
5757
orderBy: {
58-
chatId: "asc",
58+
createdAt: "asc",
5959
},
6060
});
6161
}

prisma/schema.prisma

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,21 @@ model Verification {
8181
// ここまでbetter-authが使う
8282

8383
model Chat {
84-
chatId Int @id @default(autoincrement())
84+
chatId String @id @default(uuid())
8585
userId String
8686
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
8787
docsId String
8888
sectionId String
89+
createdAt DateTime @default(now())
8990
9091
messages Message[]
9192
}
9293

9394
model Message {
94-
id Int @id @default(autoincrement())
95-
chatId Int
95+
id String @id @default(uuid())
96+
chatId String
9697
chat Chat @relation(fields: [chatId], references: [chatId], onDelete: Cascade)
9798
role String
9899
content String
100+
createdAt DateTime @default(now())
99101
}

0 commit comments

Comments
 (0)