therapist/prisma/schema.prisma

66 lines
1.3 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Session {
id String @id @default(auto()) @map("_id") @db.ObjectId
startedAt DateTime @default(now())
transferedAt DateTime?
endedAt DateTime?
callId String @unique
callerPhone String
summary String?
operatorPhone String?
operator Operator? @relation(fields: [operatorPhone], references: [phoneNumber])
messages Message[]
}
enum Role {
USER
BOT
OPERATOR
}
model Message {
id String @id @default(auto()) @map("_id") @db.ObjectId
createdAt DateTime @default(now())
role Role
content String @default("")
session Session @relation(fields: [sessionId], references: [id])
sessionId String @db.ObjectId
}
model Operator {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
phoneNumber String? @unique
email String @unique
sessions Session[]
webSession WebSession?
}
model WebSession {
id String @id @default(auto()) @map("_id") @db.ObjectId
createdAt DateTime @default(now())
token String @unique
operator Operator? @relation(fields: [operatorId], references: [id])
operatorId String? @db.ObjectId @unique
}