feat: add TicketComment, TicketAttachment models + notification ticketId

This commit is contained in:
kevin-asprec
2026-05-04 16:36:55 +08:00
parent 29c6b70878
commit 555327a891
2 changed files with 77 additions and 4 deletions

View File

@@ -43,8 +43,7 @@ model User {
password String
firstName String
lastName String
isActive Boolean @default(true)
mustChangePassword Boolean @default(false)
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@@ -54,6 +53,7 @@ model User {
tenantRoles UserTenantRole[]
assignedTickets Ticket[] @relation("TicketAssignee")
createdTickets Ticket[] @relation("TicketCreator")
authoredComments TicketComment[] @relation("CommentAuthor")
payments Payment[]
remittances Remittance[] @relation("RemittanceCollector")
confirmedRemittances Remittance[] @relation("RemittanceConfirmer")
@@ -201,8 +201,6 @@ model Client {
phone String?
address String
areaId String?
latitude Float?
longitude Float?
status String @default("active") // active, inactive, suspended
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -364,6 +362,7 @@ model Ticket {
client Client? @relation(fields: [clientId], references: [id])
createdBy User @relation("TicketCreator", fields: [createdById], references: [id])
assignee User? @relation("TicketAssignee", fields: [assigneeId], references: [id])
comments TicketComment[]
@@index([tenantId])
@@index([tenantId, type, status])
@@ -386,6 +385,7 @@ model Notification {
message String
isRead Boolean @default(false)
sentAt DateTime?
ticketId String?
createdAt DateTime @default(now())
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
@@ -395,6 +395,41 @@ model Notification {
@@map("notifications")
}
// ─── Ticket Comments ──────────────────────────────────────────────────
model TicketComment {
id String @id @default(uuid())
tenantId String
ticketId String
userId String
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
author User @relation("CommentAuthor", fields: [userId], references: [id])
attachments TicketAttachment[]
@@index([ticketId])
@@index([tenantId])
@@map("ticket_comments")
}
model TicketAttachment {
id String @id @default(uuid())
commentId String
fileName String
filePath String
fileType String
fileSize Int
createdAt DateTime @default(now())
comment TicketComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
@@map("ticket_attachments")
}
// ─── Audit Log (append-only, no soft delete) ────────────────────────
model AuditLog {