Update schema

This commit is contained in:
Isaac 2022-04-27 00:08:07 +01:00
parent da7a2784ea
commit aa0a265dbf

View File

@ -9,6 +9,7 @@ datasource db {
model ArchivedChannel { model ArchivedChannel {
channelId String @db.VarChar(19) channelId String @db.VarChar(19)
createdAt DateTime @default(now())
name String name String
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String @db.VarChar(19) ticketId String @db.VarChar(19)
@ -22,6 +23,7 @@ model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId]) author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId])
authorId String @db.VarChar(19) authorId String @db.VarChar(19)
content String content String
createdAt DateTime @default(now())
deleted Boolean @default(false) deleted Boolean @default(false)
edited Boolean @default(false) edited Boolean @default(false)
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
@ -34,6 +36,7 @@ model ArchivedMessage {
model ArchivedRole { model ArchivedRole {
archivedUsers ArchivedUser[] archivedUsers ArchivedUser[]
colour String @default("7289DA") @db.Char(6) colour String @default("7289DA") @db.Char(6)
createdAt DateTime @default(now())
name String name String
roleId String @db.VarChar(19) roleId String @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
@ -48,6 +51,7 @@ model ArchivedUser {
archivedMessages ArchivedMessage[] archivedMessages ArchivedMessage[]
avatar String avatar String
bot Boolean @default(false) bot Boolean @default(false)
createdAt DateTime @default(now())
discriminator String @db.Char(4) discriminator String @db.Char(4)
displayName String displayName String
role ArchivedRole @relation(fields: [ticketId, roleId], references: [ticketId, roleId]) role ArchivedRole @relation(fields: [ticketId, roleId], references: [ticketId, roleId])
@ -65,6 +69,7 @@ model ArchivedUser {
model Category { model Category {
channelName String @default("ticket-{num}") channelName String @default("ticket-{num}")
claiming Boolean @default(false) claiming Boolean @default(false)
createdAt DateTime @default(now())
description String description String
discordCategory String @db.VarChar(19) discordCategory String @db.VarChar(19)
emoji String emoji String
@ -76,12 +81,10 @@ model Category {
name String name String
openingMessage String @db.Text openingMessage String @db.Text
pingRoles Json @default("[]") pingRoles Json @default("[]")
questions Question[]
requiredRoles Json requiredRoles Json
requireTopic Boolean @default(false) requireTopic Boolean @default(false)
staffRoles Json staffRoles Json
surveyDescription String?
surveyLink String?
surveyTitle String?
tickets Ticket[] tickets Ticket[]
totalLimit Int @default(-1) totalLimit Int @default(-1)
@ -92,8 +95,10 @@ model Guild {
archive Boolean @default(true) archive Boolean @default(true)
blocklist Json blocklist Json
categories Category[] categories Category[]
createdAt DateTime @default(now())
errorColour String @default("RED") errorColour String @default("RED")
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
logChannel String? @db.VarChar(19)
primaryColour String @default("#009999") primaryColour String @default("#009999")
successColour String @default("GREEN") successColour String @default("GREEN")
tags Tag[] tags Tag[]
@ -102,12 +107,43 @@ model Guild {
@@map("guilds") @@map("guilds")
} }
model Question {
answers QuestionAnswer[]
id Int @id @default(autoincrement())
category Category? @relation(fields: [categoryId], references: [id])
categoryId Int?
maxLength Int @default(4000)
minLength Int @default(0)
order Int?
placeholder String? @db.VarChar(100)
required Boolean @default(true)
style Int @default(2)
value String? @db.VarChar(4000)
@@map("questions")
}
model QuestionAnswer {
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)
value String? @db.VarChar(4000)
@@map("questionAnswers")
}
model Tag { model Tag {
content String content String
createdAt DateTime @default(now())
guild Guild @relation(fields: [guildId], references: [id]) guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
regex String?
@@unique([guildId, name]) @@unique([guildId, name])
@@map("tags") @@map("tags")
@ -125,34 +161,46 @@ model Ticket {
closedBy User @relation(name: "TicketsClosedByUser", fields: [closedById], references: [id]) closedBy User @relation(name: "TicketsClosedByUser", fields: [closedById], references: [id])
closedById String @db.VarChar(19) closedById String @db.VarChar(19)
closedReason String? closedReason String?
createdAt DateTime @default(now())
createdBy User @relation(name: "TicketsCreatedByUser", fields: [createdById], references: [id]) createdBy User @relation(name: "TicketsCreatedByUser", fields: [createdById], references: [id])
createdById String @db.VarChar(19) createdById String @db.VarChar(19)
firstResponse DateTime? firstResponseAt DateTime?
deleted Boolean @default(false) deleted Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id]) guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
lastMessage DateTime? lastMessageAt DateTime?
messageCount Int? messageCount Int?
number Int number Int
open Boolean @default(true) open Boolean @default(true)
openingMessage String @db.VarChar(19) openingMessage String @db.VarChar(19)
pinnedMessages Json @default("[]") pinnedMessages Json @default("[]")
priority Priority?
referencedBy Ticket[] @relation("TicketsReferencedByTicket") referencedBy Ticket[] @relation("TicketsReferencedByTicket")
references Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesId], references: [id], onDelete: SetNull) referencesMessageId String @db.VarChar(19)
referencesId String? @db.VarChar(19) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull)
referencesTicketId String? @db.VarChar(19)
topic String? topic String?
questionAnswers QuestionAnswer[]
@@unique([guildId, number]) @@unique([guildId, number])
@@map("tickets") @@map("tickets")
} }
model User { model User {
createdAt DateTime @default(now())
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
messageCount Int @default(0) messageCount Int @default(0)
ticketsCreated Ticket[] @relation("TicketsCreatedByUser") ticketsCreated Ticket[] @relation("TicketsCreatedByUser")
ticketsClosed Ticket[] @relation("TicketsClosedByUser") ticketsClosed Ticket[] @relation("TicketsClosedByUser")
ticketsClaimed Ticket[] @relation("TicketsClaimedByUser") ticketsClaimed Ticket[] @relation("TicketsClaimedByUser")
questionAnswers QuestionAnswer[]
@@map("users") @@map("users")
} }
enum Priority {
LOW
MEDIUM
HIGH
}