65 lines
2.0 KiB
Plaintext
65 lines
2.0 KiB
Plaintext
// 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 {
|
||
provider = "postgresql"
|
||
url = env("DATABASE_URL")
|
||
}
|
||
|
||
model User {
|
||
id String @id @default(cuid())
|
||
email String @unique
|
||
name String?
|
||
password String
|
||
role String @default("DOMAIN_ADMIN") // SUPER_ADMIN or DOMAIN_ADMIN
|
||
domains String[] @default([]) // ["*"] or list of domains
|
||
telegramId String?
|
||
mailboxMappings MailboxMapping[]
|
||
notificationConfigs NotificationConfig[]
|
||
notificationLogs NotificationLog[]
|
||
createdAt DateTime @default(now())
|
||
updatedAt DateTime @updatedAt
|
||
}
|
||
|
||
model MailboxMapping {
|
||
id String @id @default(cuid())
|
||
email String @unique
|
||
userId String
|
||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
createdAt DateTime @default(now())
|
||
}
|
||
|
||
model NotificationConfig {
|
||
id String @id @default(cuid())
|
||
userId String
|
||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
type String // e.g., "TELEGRAM", "WEBHOOK"
|
||
value String // e.g., chat_id or webhook url
|
||
active Boolean @default(true)
|
||
createdAt DateTime @default(now())
|
||
}
|
||
|
||
model NotificationLog {
|
||
id String @id @default(cuid())
|
||
mailbox String // Bildirim gelen mail adresi
|
||
sender String? // Gönderen kişi
|
||
subject String? // Konu
|
||
status String // "SENT", "FAILED"
|
||
error String? // Hata varsa detayı
|
||
userId String? // Hangi kullanıcıya bildirim gittiği
|
||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||
createdAt DateTime @default(now())
|
||
}
|
||
|
||
model SystemLog {
|
||
id String @id @default(cuid())
|
||
level String // "INFO", "WARN", "ERROR"
|
||
message String
|
||
details String?
|
||
createdAt DateTime @default(now())
|
||
}
|