feat: ajustar board de tickets
This commit is contained in:
parent
e9a8bd6b9b
commit
d23987eda8
7 changed files with 434 additions and 429 deletions
|
|
@ -4,42 +4,42 @@ generator client {
|
|||
// and container runtime (Debian bullseye, OpenSSL 1.1.x)
|
||||
binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum UserRole {
|
||||
ADMIN
|
||||
MANAGER
|
||||
AGENT
|
||||
COLLABORATOR
|
||||
}
|
||||
|
||||
|
||||
enum TicketStatus {
|
||||
PENDING
|
||||
AWAITING_ATTENDANCE
|
||||
PAUSED
|
||||
RESOLVED
|
||||
}
|
||||
|
||||
enum TicketPriority {
|
||||
LOW
|
||||
MEDIUM
|
||||
HIGH
|
||||
URGENT
|
||||
}
|
||||
|
||||
enum TicketChannel {
|
||||
EMAIL
|
||||
WHATSAPP
|
||||
CHAT
|
||||
PHONE
|
||||
API
|
||||
MANUAL
|
||||
}
|
||||
|
||||
|
||||
enum TicketPriority {
|
||||
LOW
|
||||
MEDIUM
|
||||
HIGH
|
||||
URGENT
|
||||
}
|
||||
|
||||
enum TicketChannel {
|
||||
EMAIL
|
||||
WHATSAPP
|
||||
CHAT
|
||||
PHONE
|
||||
API
|
||||
MANUAL
|
||||
}
|
||||
|
||||
enum CommentVisibility {
|
||||
PUBLIC
|
||||
INTERNAL
|
||||
|
|
@ -56,66 +56,66 @@ model Team {
|
|||
tenantId String
|
||||
name String
|
||||
description String?
|
||||
members TeamMember[]
|
||||
queues Queue[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([tenantId, name])
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
teamId String
|
||||
userId String
|
||||
isLead Boolean @default(false)
|
||||
assignedAt DateTime @default(now())
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([teamId, userId])
|
||||
}
|
||||
|
||||
members TeamMember[]
|
||||
queues Queue[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([tenantId, name])
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
teamId String
|
||||
userId String
|
||||
isLead Boolean @default(false)
|
||||
assignedAt DateTime @default(now())
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([teamId, userId])
|
||||
}
|
||||
|
||||
model Company {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
slug String
|
||||
provisioningCode String @unique
|
||||
isAvulso Boolean @default(false)
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
slug String
|
||||
provisioningCode String @unique
|
||||
isAvulso Boolean @default(false)
|
||||
contractedHoursPerMonth Float?
|
||||
cnpj String?
|
||||
domain String?
|
||||
phone String?
|
||||
description String?
|
||||
address String?
|
||||
legalName String?
|
||||
tradeName String?
|
||||
stateRegistration String?
|
||||
stateRegistrationType CompanyStateRegistrationType?
|
||||
primaryCnae String?
|
||||
timezone String?
|
||||
businessHours Json?
|
||||
supportEmail String?
|
||||
billingEmail String?
|
||||
contactPreferences Json?
|
||||
clientDomains Json?
|
||||
communicationChannels Json?
|
||||
fiscalAddress Json?
|
||||
hasBranches Boolean @default(false)
|
||||
regulatedEnvironments Json?
|
||||
privacyPolicyAccepted Boolean @default(false)
|
||||
privacyPolicyReference String?
|
||||
privacyPolicyMetadata Json?
|
||||
contacts Json?
|
||||
locations Json?
|
||||
contracts Json?
|
||||
sla Json?
|
||||
tags Json?
|
||||
customFields Json?
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
cnpj String?
|
||||
domain String?
|
||||
phone String?
|
||||
description String?
|
||||
address String?
|
||||
legalName String?
|
||||
tradeName String?
|
||||
stateRegistration String?
|
||||
stateRegistrationType CompanyStateRegistrationType?
|
||||
primaryCnae String?
|
||||
timezone String?
|
||||
businessHours Json?
|
||||
supportEmail String?
|
||||
billingEmail String?
|
||||
contactPreferences Json?
|
||||
clientDomains Json?
|
||||
communicationChannels Json?
|
||||
fiscalAddress Json?
|
||||
hasBranches Boolean @default(false)
|
||||
regulatedEnvironments Json?
|
||||
privacyPolicyAccepted Boolean @default(false)
|
||||
privacyPolicyReference String?
|
||||
privacyPolicyMetadata Json?
|
||||
contacts Json?
|
||||
locations Json?
|
||||
contracts Json?
|
||||
sla Json?
|
||||
tags Json?
|
||||
customFields Json?
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
users User[]
|
||||
tickets Ticket[]
|
||||
|
|
@ -124,121 +124,121 @@ model Company {
|
|||
@@index([tenantId, name])
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
email String @unique
|
||||
role UserRole
|
||||
timezone String @default("America/Sao_Paulo")
|
||||
avatarUrl String?
|
||||
companyId String?
|
||||
teams TeamMember[]
|
||||
requestedTickets Ticket[] @relation("TicketRequester")
|
||||
assignedTickets Ticket[] @relation("TicketAssignee")
|
||||
comments TicketComment[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
email String @unique
|
||||
role UserRole
|
||||
timezone String @default("America/Sao_Paulo")
|
||||
avatarUrl String?
|
||||
companyId String?
|
||||
teams TeamMember[]
|
||||
requestedTickets Ticket[] @relation("TicketRequester")
|
||||
assignedTickets Ticket[] @relation("TicketAssignee")
|
||||
comments TicketComment[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
company Company? @relation(fields: [companyId], references: [id])
|
||||
|
||||
@@index([tenantId, role])
|
||||
@@index([tenantId, role])
|
||||
@@index([tenantId, companyId])
|
||||
}
|
||||
|
||||
model Queue {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
slug String
|
||||
teamId String?
|
||||
tickets Ticket[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
|
||||
@@unique([tenantId, slug])
|
||||
}
|
||||
|
||||
model Ticket {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
reference Int @default(0)
|
||||
subject String
|
||||
summary String?
|
||||
status TicketStatus @default(PENDING)
|
||||
priority TicketPriority @default(MEDIUM)
|
||||
channel TicketChannel @default(EMAIL)
|
||||
queueId String?
|
||||
requesterId String
|
||||
assigneeId String?
|
||||
slaPolicyId String?
|
||||
companyId String?
|
||||
dueAt DateTime?
|
||||
firstResponseAt DateTime?
|
||||
resolvedAt DateTime?
|
||||
closedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
requester User @relation("TicketRequester", fields: [requesterId], references: [id])
|
||||
assignee User? @relation("TicketAssignee", fields: [assigneeId], references: [id])
|
||||
queue Queue? @relation(fields: [queueId], references: [id])
|
||||
slaPolicy SlaPolicy? @relation(fields: [slaPolicyId], references: [id])
|
||||
company Company? @relation(fields: [companyId], references: [id])
|
||||
events TicketEvent[]
|
||||
comments TicketComment[]
|
||||
|
||||
@@index([tenantId, status])
|
||||
@@index([tenantId, queueId])
|
||||
@@index([tenantId, assigneeId])
|
||||
}
|
||||
|
||||
model Queue {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
slug String
|
||||
teamId String?
|
||||
tickets Ticket[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
|
||||
@@unique([tenantId, slug])
|
||||
}
|
||||
|
||||
model Ticket {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
reference Int @default(0)
|
||||
subject String
|
||||
summary String?
|
||||
status TicketStatus @default(PENDING)
|
||||
priority TicketPriority @default(MEDIUM)
|
||||
channel TicketChannel @default(EMAIL)
|
||||
queueId String?
|
||||
requesterId String
|
||||
assigneeId String?
|
||||
slaPolicyId String?
|
||||
companyId String?
|
||||
dueAt DateTime?
|
||||
firstResponseAt DateTime?
|
||||
resolvedAt DateTime?
|
||||
closedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
requester User @relation("TicketRequester", fields: [requesterId], references: [id])
|
||||
assignee User? @relation("TicketAssignee", fields: [assigneeId], references: [id])
|
||||
queue Queue? @relation(fields: [queueId], references: [id])
|
||||
slaPolicy SlaPolicy? @relation(fields: [slaPolicyId], references: [id])
|
||||
company Company? @relation(fields: [companyId], references: [id])
|
||||
events TicketEvent[]
|
||||
comments TicketComment[]
|
||||
|
||||
@@index([tenantId, status])
|
||||
@@index([tenantId, queueId])
|
||||
@@index([tenantId, assigneeId])
|
||||
@@index([tenantId, companyId])
|
||||
}
|
||||
|
||||
model TicketEvent {
|
||||
id String @id @default(cuid())
|
||||
ticketId String
|
||||
type String
|
||||
payload Json
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([ticketId, createdAt])
|
||||
}
|
||||
|
||||
model TicketComment {
|
||||
id String @id @default(cuid())
|
||||
ticketId String
|
||||
authorId String
|
||||
visibility CommentVisibility @default(INTERNAL)
|
||||
body String
|
||||
attachments Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
author User @relation(fields: [authorId], references: [id])
|
||||
|
||||
@@index([ticketId, visibility])
|
||||
}
|
||||
|
||||
model SlaPolicy {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
description String?
|
||||
timeToFirstResponse Int?
|
||||
timeToResolution Int?
|
||||
calendar Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tickets Ticket[]
|
||||
|
||||
@@unique([tenantId, name])
|
||||
}
|
||||
}
|
||||
|
||||
model TicketEvent {
|
||||
id String @id @default(cuid())
|
||||
ticketId String
|
||||
type String
|
||||
payload Json
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([ticketId, createdAt])
|
||||
}
|
||||
|
||||
model TicketComment {
|
||||
id String @id @default(cuid())
|
||||
ticketId String
|
||||
authorId String
|
||||
visibility CommentVisibility @default(INTERNAL)
|
||||
body String
|
||||
attachments Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
author User @relation(fields: [authorId], references: [id])
|
||||
|
||||
@@index([ticketId, visibility])
|
||||
}
|
||||
|
||||
model SlaPolicy {
|
||||
id String @id @default(cuid())
|
||||
tenantId String
|
||||
name String
|
||||
description String?
|
||||
timeToFirstResponse Int?
|
||||
timeToResolution Int?
|
||||
calendar Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
tickets Ticket[]
|
||||
|
||||
@@unique([tenantId, name])
|
||||
}
|
||||
|
||||
model AuthUser {
|
||||
id String @id @default(cuid())
|
||||
|
|
@ -257,14 +257,14 @@ model AuthUser {
|
|||
}
|
||||
|
||||
model AuthSession {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ model AuthSession {
|
|||
}
|
||||
|
||||
model AuthAccount {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
accountId String
|
||||
providerId String
|
||||
|
|
@ -284,8 +284,8 @@ model AuthAccount {
|
|||
scope String?
|
||||
idToken String?
|
||||
password String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
|
|
@ -294,24 +294,24 @@ model AuthAccount {
|
|||
}
|
||||
|
||||
model AuthInvite {
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
name String?
|
||||
role String @default("agent")
|
||||
tenantId String
|
||||
token String @unique
|
||||
status String @default("pending")
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdById String?
|
||||
acceptedAt DateTime?
|
||||
acceptedById String?
|
||||
revokedAt DateTime?
|
||||
revokedById String?
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
name String?
|
||||
role String @default("agent")
|
||||
tenantId String
|
||||
token String @unique
|
||||
status String @default("pending")
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdById String?
|
||||
acceptedAt DateTime?
|
||||
acceptedById String?
|
||||
revokedAt DateTime?
|
||||
revokedById String?
|
||||
revokedReason String?
|
||||
|
||||
events AuthInviteEvent[]
|
||||
events AuthInviteEvent[]
|
||||
|
||||
@@index([tenantId, status])
|
||||
@@index([tenantId, email])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue