101 lines
2.5 KiB
Plaintext
101 lines
2.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model AdminUser {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
password String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String
|
|
platform String
|
|
originalPlatformId String
|
|
groups Group[] // многие-ко-многим!
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([platform, originalPlatformId])
|
|
}
|
|
|
|
|
|
|
|
model Group {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
icon String? // новая опциональная иконка
|
|
users User[]
|
|
bots Bot[] @relation("BotGroups")
|
|
commands Command[] @relation("CommandGroups")
|
|
}
|
|
|
|
model Command {
|
|
id String @id @default(cuid())
|
|
command String
|
|
description String? // новое опциональное описание
|
|
groupIds Group[] @relation("CommandGroups")
|
|
bots Bot[] @relation("BotCommands")
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Bot {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
isActive Boolean @default(true)
|
|
groups Group[] @relation("BotGroups")
|
|
commands Command[] @relation("BotCommands")
|
|
description String?
|
|
exampleMessages BotExampleMessage[]
|
|
externalBots ExternalBot[] @relation("BotsInInterface")
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model BotExampleMessage {
|
|
id String @id @default(cuid())
|
|
botId String
|
|
text String
|
|
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model ChatState {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
externalBotId String // <-- ссылка на внешний бот
|
|
stateJson Json
|
|
lockedByBot String
|
|
updatedAt DateTime @updatedAt
|
|
externalBot ExternalBot @relation(fields: [externalBotId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, externalBotId])
|
|
}
|
|
|
|
|
|
|
|
model Log {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
botId String
|
|
direction String
|
|
message String
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
|
|
model ExternalBot {
|
|
id String @id @default(cuid())
|
|
name String
|
|
token String @unique
|
|
bots Bot[] @relation("BotsInInterface")
|
|
chatStates ChatState[] // <--- вот это поле нужно добавить!
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
|