Init
This commit is contained in:
198
backend/prisma/schema.prisma
Normal file
198
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,198 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum MailProvider {
|
||||
GMAIL
|
||||
GMX
|
||||
WEBDE
|
||||
}
|
||||
|
||||
enum JobStatus {
|
||||
QUEUED
|
||||
RUNNING
|
||||
SUCCEEDED
|
||||
FAILED
|
||||
CANCELED
|
||||
}
|
||||
|
||||
enum RuleActionType {
|
||||
MOVE
|
||||
DELETE
|
||||
ARCHIVE
|
||||
LABEL
|
||||
}
|
||||
|
||||
enum RuleConditionType {
|
||||
HEADER
|
||||
SUBJECT
|
||||
FROM
|
||||
LIST_UNSUBSCRIBE
|
||||
LIST_ID
|
||||
}
|
||||
|
||||
model Tenant {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
users User[]
|
||||
mailboxAccounts MailboxAccount[]
|
||||
rules Rule[]
|
||||
jobs CleanupJob[]
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
email String @unique
|
||||
password String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tenant Tenant @relation(fields: [tenantId], references: [id])
|
||||
}
|
||||
|
||||
model MailboxAccount {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
email String
|
||||
provider MailProvider
|
||||
imapHost String
|
||||
imapPort Int
|
||||
imapTLS Boolean
|
||||
smtpHost String?
|
||||
smtpPort Int?
|
||||
smtpTLS Boolean?
|
||||
oauthToken String?
|
||||
appPassword String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tenant Tenant @relation(fields: [tenantId], references: [id])
|
||||
folders MailboxFolder[]
|
||||
jobs CleanupJob[]
|
||||
|
||||
@@index([tenantId])
|
||||
}
|
||||
|
||||
model MailboxFolder {
|
||||
id String @id @default(cuid())
|
||||
mailboxAccountId String
|
||||
name String
|
||||
remoteId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
mailboxAccount MailboxAccount @relation(fields: [mailboxAccountId], references: [id])
|
||||
mailItems MailItem[]
|
||||
|
||||
@@index([mailboxAccountId])
|
||||
}
|
||||
|
||||
model MailItem {
|
||||
id String @id @default(cuid())
|
||||
folderId String
|
||||
messageId String
|
||||
subject String?
|
||||
from String?
|
||||
receivedAt DateTime?
|
||||
listId String?
|
||||
listUnsubscribe String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
folder MailboxFolder @relation(fields: [folderId], references: [id])
|
||||
|
||||
@@index([folderId])
|
||||
@@index([messageId])
|
||||
}
|
||||
|
||||
model Rule {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
enabled Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tenant Tenant @relation(fields: [tenantId], references: [id])
|
||||
conditions RuleCondition[]
|
||||
actions RuleAction[]
|
||||
|
||||
@@index([tenantId])
|
||||
}
|
||||
|
||||
model RuleCondition {
|
||||
id String @id @default(cuid())
|
||||
ruleId String
|
||||
type RuleConditionType
|
||||
value String
|
||||
|
||||
rule Rule @relation(fields: [ruleId], references: [id])
|
||||
|
||||
@@index([ruleId])
|
||||
}
|
||||
|
||||
model RuleAction {
|
||||
id String @id @default(cuid())
|
||||
ruleId String
|
||||
type RuleActionType
|
||||
target String?
|
||||
|
||||
rule Rule @relation(fields: [ruleId], references: [id])
|
||||
|
||||
@@index([ruleId])
|
||||
}
|
||||
|
||||
model CleanupJob {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
mailboxAccountId String
|
||||
status JobStatus @default(QUEUED)
|
||||
startedAt DateTime?
|
||||
finishedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tenant Tenant @relation(fields: [tenantId], references: [id])
|
||||
mailboxAccount MailboxAccount @relation(fields: [mailboxAccountId], references: [id])
|
||||
unsubscribeAttempts UnsubscribeAttempt[]
|
||||
events CleanupJobEvent[]
|
||||
|
||||
@@index([tenantId])
|
||||
@@index([mailboxAccountId])
|
||||
}
|
||||
|
||||
model UnsubscribeAttempt {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
mailItemId String?
|
||||
method String
|
||||
target String
|
||||
status String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
job CleanupJob @relation(fields: [jobId], references: [id])
|
||||
|
||||
@@index([jobId])
|
||||
}
|
||||
|
||||
model CleanupJobEvent {
|
||||
id String @id @default(cuid())
|
||||
jobId String
|
||||
level String
|
||||
message String
|
||||
progress Int?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
job CleanupJob @relation(fields: [jobId], references: [id])
|
||||
|
||||
@@index([jobId])
|
||||
}
|
||||
Reference in New Issue
Block a user