94 lines
2.3 KiB
Plaintext
94 lines
2.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Group {
|
|
id String @id @default(cuid())
|
|
platform String
|
|
platformId String
|
|
name String
|
|
description String?
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
messages Message[]
|
|
syncRoutesFrom SyncRoute[] @relation("sourceGroup")
|
|
syncRoutesTo SyncRoute[] @relation("targetGroup")
|
|
consentRecords ConsentRecord[]
|
|
|
|
@@unique([platform, platformId])
|
|
}
|
|
|
|
model Message {
|
|
id String @id @default(cuid())
|
|
platform String
|
|
platformMsgId String
|
|
sourceGroupId String
|
|
sourceGroup Group @relation(fields: [sourceGroupId], references: [id])
|
|
senderJid String
|
|
senderName String?
|
|
content String
|
|
mediaUrl String?
|
|
tags String[]
|
|
status MessageStatus @default(PENDING)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
approval Approval?
|
|
|
|
@@unique([platform, platformMsgId])
|
|
}
|
|
|
|
enum MessageStatus {
|
|
PENDING
|
|
APPROVED
|
|
REJECTED
|
|
DISTRIBUTED
|
|
ARCHIVED
|
|
}
|
|
|
|
model Approval {
|
|
id String @id @default(cuid())
|
|
messageId String @unique
|
|
message Message @relation(fields: [messageId], references: [id])
|
|
adminId String
|
|
decision ApprovalDecision
|
|
notes String?
|
|
decidedAt DateTime @default(now())
|
|
}
|
|
|
|
enum ApprovalDecision {
|
|
APPROVED
|
|
REJECTED
|
|
}
|
|
|
|
model SyncRoute {
|
|
id String @id @default(cuid())
|
|
sourceGroupId String
|
|
sourceGroup Group @relation("sourceGroup", fields: [sourceGroupId], references: [id])
|
|
targetGroupId String
|
|
targetGroup Group @relation("targetGroup", fields: [targetGroupId], references: [id])
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([sourceGroupId, targetGroupId])
|
|
}
|
|
|
|
model ConsentRecord {
|
|
id String @id @default(cuid())
|
|
groupId String
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
memberJid String
|
|
consentType String
|
|
grantedAt DateTime @default(now())
|
|
revokedAt DateTime?
|
|
|
|
@@unique([groupId, memberJid, consentType])
|
|
}
|