fix: SSE 认证 + 收藏去重 + 数据库索引和级联删除
- #7: SSE events 接口校验 userId 房间成员身份,start() 加 try/catch - #9: Favorite 新增 restaurantId 字段做精确去重,不再用 JSON contains - #10: 补齐 Decision/Favorite/Room/BlindBoxIdea 缺失索引 - #11: Decision/Favorite/BlindBoxMember/BlindBoxIdea 加 onDelete Cascade
This commit is contained in:
+17
-5
@@ -12,6 +12,8 @@ model Room {
|
||||
data String
|
||||
createdAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
|
||||
@@index([expiresAt])
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -40,15 +42,22 @@ model Decision {
|
||||
matchType String
|
||||
participants Int
|
||||
createdAt DateTime @default(now())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@index([roomId])
|
||||
}
|
||||
|
||||
model Favorite {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
restaurantId String @default("")
|
||||
restaurantData String
|
||||
createdAt DateTime @default(now())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, restaurantId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model BlindBoxRoom {
|
||||
@@ -70,7 +79,7 @@ model BlindBoxMember {
|
||||
joinedAt DateTime @default(now())
|
||||
|
||||
room BlindBoxRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([roomId, userId])
|
||||
}
|
||||
@@ -85,6 +94,9 @@ model BlindBoxIdea {
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
room BlindBoxRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
||||
user User @relation("IdeaSubmitter", fields: [userId], references: [id])
|
||||
drawnBy User? @relation("IdeaDrawer", fields: [drawnById], references: [id])
|
||||
user User @relation("IdeaSubmitter", fields: [userId], references: [id], onDelete: Cascade)
|
||||
drawnBy User? @relation("IdeaDrawer", fields: [drawnById], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([roomId, status])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user