Q2TG/prisma/schema.prisma

121 lines
3.3 KiB
Plaintext
Raw Normal View History

2022-02-15 10:06:36 +00:00
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
2022-02-20 08:25:30 +00:00
provider = "postgresql"
url = env("DATABASE_URL")
2022-02-15 10:06:36 +00:00
}
model Session {
id Int @id @default(autoincrement())
dcId Int?
port Int?
serverAddress String?
authKey Bytes?
entities Entity[]
}
model Entity {
id Int @id @default(autoincrement())
// 源代码里面大概支持 string 和 BigInteger不如先全都存 String
entityId String
sessionId Int
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
hash String?
username String?
phone String?
name String?
@@unique([entityId, sessionId])
}
model Instance {
id Int @id @default(autoincrement())
owner BigInt @default(0)
workMode String @default("")
isSetup Boolean @default(false)
Message Message[]
ForwardPair ForwardPair[]
botSessionId Int?
userSessionId Int?
qqBotId Int?
qqBot QqBot? @relation(fields: [qqBotId], references: [id], onDelete: Cascade)
2022-12-23 08:41:20 +00:00
reportUrl String?
}
model QqBot {
id Int @id @default(autoincrement())
uin BigInt @default(0)
password String @default("")
platform Int @default(0)
Instance Instance[]
}
2022-02-15 10:06:36 +00:00
model Message {
2022-02-23 09:11:04 +00:00
id Int @id @default(autoincrement())
qqRoomId BigInt @db.BigInt
qqSenderId BigInt @db.BigInt
time Int
brief String?
2022-02-23 09:11:04 +00:00
seq Int
rand BigInt @db.BigInt
2022-02-23 09:11:04 +00:00
pktnum Int
tgChatId BigInt @db.BigInt
2022-02-23 09:11:04 +00:00
tgMsgId Int
instanceId Int @default(0)
instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
2022-02-15 15:23:03 +00:00
@@index([qqRoomId, qqSenderId, seq, rand, pktnum, time, instanceId])
@@index([tgChatId, tgMsgId, instanceId])
2022-02-15 15:23:03 +00:00
}
model ForwardPair {
2022-02-23 09:11:04 +00:00
id Int @id @default(autoincrement())
2022-03-07 12:58:56 +00:00
qqRoomId BigInt @db.BigInt
tgChatId BigInt @db.BigInt
avatarCache AvatarCache[]
instanceId Int @default(0)
instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
2022-04-07 05:32:15 +00:00
joinNotice Boolean @default(true)
poke Boolean @default(true)
enable Boolean @default(true)
2022-10-17 13:19:24 +00:00
disableQ2TG Boolean @default(false)
disableTG2Q Boolean @default(false)
2022-03-07 12:58:56 +00:00
@@unique([qqRoomId, instanceId])
@@unique([tgChatId, instanceId])
2022-02-15 15:23:03 +00:00
}
model File {
id Int @id @default(autoincrement())
roomId BigInt @db.BigInt
fileId String
info String
2022-02-15 15:23:03 +00:00
}
model FlashPhoto {
id Int @id @default(autoincrement())
2022-02-23 09:11:04 +00:00
photoMd5 String
views FlashPhotoView[]
2022-02-15 10:06:36 +00:00
}
2022-02-15 15:23:03 +00:00
model FlashPhotoView {
id Int @id @default(autoincrement())
2022-02-23 09:11:04 +00:00
flashPhotoId Int
flashPhoto FlashPhoto @relation(fields: [flashPhotoId], references: [id])
viewerId BigInt @db.BigInt
2022-02-15 15:23:03 +00:00
@@unique([flashPhotoId, viewerId])
}
2022-02-23 09:11:04 +00:00
model AvatarCache {
id Int @id @default(autoincrement())
forwardPair ForwardPair @relation(fields: [forwardPairId], references: [id], onDelete: Cascade)
2022-02-23 09:11:04 +00:00
forwardPairId Int @unique
2022-03-02 11:40:51 +00:00
hash Bytes
2022-02-23 09:11:04 +00:00
}