DiscordTickets/prisma/schema.prisma

233 lines
8.2 KiB
Plaintext
Raw Normal View History

2022-03-22 01:28:20 +02:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DB_CONNECTION_URL")
}
2022-03-23 00:05:22 +02:00
model ArchivedChannel {
2022-04-27 02:08:07 +03:00
channelId String @db.VarChar(19)
createdAt DateTime @default(now())
2022-03-23 00:05:22 +02:00
name String
2022-04-27 02:08:07 +03:00
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
2022-03-23 00:05:22 +02:00
@@id([ticketId, channelId])
@@unique([ticketId, channelId])
2022-04-22 02:35:07 +03:00
@@map("archivedChannels")
2022-03-23 00:05:22 +02:00
}
model ArchivedMessage {
2022-04-27 17:26:18 +03:00
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade)
2022-04-27 02:08:07 +03:00
authorId String @db.VarChar(19)
2022-04-27 17:19:16 +03:00
content String @db.Text
2022-04-27 02:08:07 +03:00
createdAt DateTime @default(now())
deleted Boolean @default(false)
edited Boolean @default(false)
id String @id @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19)
2022-03-23 00:05:22 +02:00
2022-04-22 02:35:07 +03:00
@@map("archivedMessages")
2022-03-23 00:05:22 +02:00
}
model ArchivedRole {
archivedUsers ArchivedUser[]
colour String @default("7289DA") @db.Char(6)
2022-04-27 02:08:07 +03:00
createdAt DateTime @default(now())
2022-03-23 00:05:22 +02:00
name String
roleId String @db.VarChar(19)
2022-04-22 02:12:53 +03:00
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
2022-03-23 00:05:22 +02:00
ticketId String @db.VarChar(19)
@@id([ticketId, roleId])
@@unique([ticketId, roleId])
2022-04-22 02:35:07 +03:00
@@map("archivedRoles")
2022-03-23 00:05:22 +02:00
}
model ArchivedUser {
archivedMessages ArchivedMessage[]
avatar String
2022-03-23 00:05:22 +02:00
bot Boolean @default(false)
2022-04-27 02:08:07 +03:00
createdAt DateTime @default(now())
2022-03-23 00:05:22 +02:00
discriminator String @db.Char(4)
displayName String
2022-04-27 17:26:18 +03:00
role ArchivedRole @relation(fields: [ticketId, roleId], references: [ticketId, roleId], onDelete: Cascade)
2022-03-23 00:05:22 +02:00
roleId String @db.VarChar(19)
2022-04-22 02:12:53 +03:00
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
2022-03-23 00:05:22 +02:00
ticketId String @db.VarChar(19)
userId String @db.VarChar(19)
username String
@@id([ticketId, userId])
@@unique([ticketId, userId])
2022-04-22 02:35:07 +03:00
@@map("archivedUsers")
2022-03-23 00:05:22 +02:00
}
2022-03-22 01:28:20 +02:00
model Category {
2022-04-27 02:08:07 +03:00
channelName String @default("ticket-{num}")
claiming Boolean @default(false)
createdAt DateTime @default(now())
description String
discordCategory String @db.VarChar(19)
emoji String
2022-04-27 02:15:12 +03:00
enableFeedback Boolean @default(false)
2022-04-27 02:08:07 +03:00
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
id Int @id @default(autoincrement())
image String?
memberLimit Int @default(1)
name String
openingMessage String @db.Text
pingRoles Json @default("[]")
questions Question[]
2022-05-04 20:41:57 +03:00
ratelimit Int?
2022-04-27 02:08:07 +03:00
requiredRoles Json
requireTopic Boolean @default(false)
staffRoles Json
tickets Ticket[]
totalLimit Int @default(-1)
2022-03-22 01:28:20 +02:00
@@map("categories")
}
2022-04-27 02:15:12 +03:00
model Feedback {
2022-04-27 17:31:47 +03:00
comment String? @db.Text
2022-04-27 17:19:16 +03:00
createdAt DateTime @default(now())
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19)
id Int @id @default(autoincrement())
rating Int
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @unique @db.VarChar(19)
user User? @relation(fields: [userId], references: [id])
userId String? @db.VarChar(19)
2022-04-27 02:15:12 +03:00
2022-04-27 17:19:16 +03:00
@@map("feedback")
2022-04-27 02:15:12 +03:00
}
2022-03-22 01:28:20 +02:00
model Guild {
2022-04-27 17:19:16 +03:00
autoTag Json?
2022-03-23 00:05:22 +02:00
archive Boolean @default(true)
2022-05-07 20:41:39 +03:00
blocklist Json @default("[]")
2022-03-23 00:05:22 +02:00
categories Category[]
2022-04-27 02:08:07 +03:00
createdAt DateTime @default(now())
2022-03-23 00:05:22 +02:00
errorColour String @default("RED")
2022-04-27 17:19:16 +03:00
feedback Feedback[]
id String @id @db.VarChar(19)
2022-04-27 02:08:07 +03:00
logChannel String? @db.VarChar(19)
2022-03-23 00:05:22 +02:00
primaryColour String @default("#009999")
successColour String @default("GREEN")
2022-03-22 01:28:20 +02:00
tags Tag[]
tickets Ticket[]
@@map("guilds")
}
2022-04-27 02:08:07 +03:00
model Question {
answers QuestionAnswer[]
2022-04-27 17:19:16 +03:00
createdAt DateTime @default(now())
2022-04-27 02:08:07 +03:00
id Int @id @default(autoincrement())
category Category? @relation(fields: [categoryId], references: [id])
categoryId Int?
2022-04-27 17:19:16 +03:00
label String
maxLength Int? @default(4000)
minLength Int? @default(0)
order Int
2022-04-27 02:08:07 +03:00
placeholder String? @db.VarChar(100)
required Boolean @default(true)
style Int @default(2)
2022-04-27 17:19:16 +03:00
value String? @db.Text
2022-04-27 02:08:07 +03:00
@@map("questions")
}
model QuestionAnswer {
2022-04-27 17:19:16 +03:00
createdAt DateTime @default(now())
2022-04-27 02:08:07 +03:00
id Int @id @default(autoincrement())
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @db.VarChar(19)
question Question @relation(fields: [questionId], references: [id])
questionId Int
user User @relation(fields: [userId], references: [id])
userId String @db.VarChar(19)
2022-04-27 17:19:16 +03:00
value String? @db.Text
2022-04-27 02:08:07 +03:00
@@map("questionAnswers")
}
2022-03-22 01:28:20 +02:00
model Tag {
2022-04-27 02:08:07 +03:00
content String
createdAt DateTime @default(now())
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
id Int @id @default(autoincrement())
name String
regex String?
2022-03-22 01:28:20 +02:00
@@unique([guildId, name])
@@map("tags")
}
model Ticket {
2022-04-27 02:08:07 +03:00
archivedChannels ArchivedChannel[]
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
categoryId Int?
claimedBy User @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
claimedById String @db.VarChar(19)
2022-04-27 19:22:13 +03:00
closedAt DateTime?
2022-04-27 02:08:07 +03:00
closedBy User @relation(name: "TicketsClosedByUser", fields: [closedById], references: [id])
closedById String @db.VarChar(19)
closedReason String?
createdAt DateTime @default(now())
createdBy User @relation(name: "TicketsCreatedByUser", fields: [createdById], references: [id])
createdById String @db.VarChar(19)
2022-04-27 02:15:12 +03:00
feedback Feedback?
feedbackId Int?
2022-04-27 02:08:07 +03:00
firstResponseAt DateTime?
deleted Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
id String @id @db.VarChar(19)
lastMessageAt DateTime?
messageCount Int?
number Int
open Boolean @default(true)
openingMessage String @db.VarChar(19)
pinnedMessages Json @default("[]")
priority Priority?
referencedBy Ticket[] @relation("TicketsReferencedByTicket")
referencesMessageId String @db.VarChar(19)
referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull)
referencesTicketId String? @db.VarChar(19)
topic String?
questionAnswers QuestionAnswer[]
2022-03-22 01:28:20 +02:00
@@unique([guildId, number])
@@map("tickets")
}
model User {
2022-04-27 02:08:07 +03:00
createdAt DateTime @default(now())
2022-04-27 02:15:12 +03:00
feedback Feedback[]
2022-04-27 02:08:07 +03:00
id String @id @db.VarChar(19)
messageCount Int @default(0)
ticketsCreated Ticket[] @relation("TicketsCreatedByUser")
ticketsClosed Ticket[] @relation("TicketsClosedByUser")
ticketsClaimed Ticket[] @relation("TicketsClaimedByUser")
questionAnswers QuestionAnswer[]
2022-03-22 01:28:20 +02:00
@@map("users")
}
2022-04-27 02:08:07 +03:00
enum Priority {
LOW
MEDIUM
HIGH
}