DiscordTickets/prisma/schema.prisma

199 lines
7.0 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 {
channelId String @db.VarChar(19)
name String
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @db.VarChar(19)
@@id([ticketId, channelId])
@@unique([ticketId, channelId])
@@map("archived_channels")
}
model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId])
authorId String @db.VarChar(19)
data Json
deleted Boolean @default(false)
edited Boolean @default(false)
id String @id @unique @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @db.VarChar(19)
@@map("archived_messages")
}
model ArchivedRole {
archivedUsers ArchivedUser[]
colour String @default("7289DA") @db.Char(6)
name String
roleId String @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @db.VarChar(19)
@@id([ticketId, roleId])
@@unique([ticketId, roleId])
@@map("archived_roles")
}
model ArchivedUser {
archivedMessages ArchivedMessage[]
avatar String
2022-03-23 00:05:22 +02:00
bot Boolean @default(false)
discriminator String @db.Char(4)
displayName String
role ArchivedRole @relation(fields: [ticketId, roleId], references: [ticketId, roleId])
roleId String @db.VarChar(19)
ticket Ticket @relation(fields: [ticketId], references: [id])
ticketId String @db.VarChar(19)
userId String @db.VarChar(19)
username String
@@id([ticketId, userId])
@@unique([ticketId, userId])
@@map("archived_users")
}
2022-03-22 01:28:20 +02:00
model Category {
2022-03-23 01:38:35 +02:00
channelName String @default("ticket-{num}")
claiming Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
id String @id @unique @db.VarChar(19)
image String?
memberLimit Int @default(1)
name String
openingMessage String @db.Text
ping Json @default("[]")
requireTopic Boolean @default(false)
roles Json
tickets Ticket[]
totalLimit Int @default(-1)
2022-04-16 16:33:46 +03:00
// survey Survey @relation(fields: [guildId, surveyName], references: [guildId, name])
2022-03-23 01:38:35 +02:00
surveyName String
2022-03-22 01:28:20 +02:00
@@map("categories")
}
model Guild {
2022-03-23 00:05:22 +02:00
archive Boolean @default(true)
categories Category[]
errorColour String @default("RED")
id String @id @unique @db.VarChar(19)
primaryColour String @default("#009999")
successColour String @default("GREEN")
2022-04-16 16:33:46 +03:00
// surveys Survey[]
2022-03-22 01:28:20 +02:00
tags Tag[]
tickets Ticket[]
@@map("guilds")
}
2022-04-16 16:33:46 +03:00
// model Survey {
// categories Category[]
// guild Guild @relation(fields: [guildId], references: [id])
// guildId String @db.VarChar(19)
// name String
// questions SurveyQuestion[]
// responses SurveyResponse[]
// @@id([guildId, name])
// @@unique([guildId, name])
// @@map("surveys")
// }
// model SurveyResponse {
// answers SurveyQuestionAnswer[]
// id Int @id @default(autoincrement())
// survey Survey @relation(fields: [surveyGuildId, surveyName], references: [guildId, name])
// surveyGuildId String @db.VarChar(19)
// surveyName String
// user User @relation(fields: [userId], references: [id])
// userId String @db.VarChar(19)
// @@map("survey_responses")
// }
// model SurveyQuestion {
// answers SurveyQuestionAnswer[]
// content String @db.Text
// id Int @id @default(autoincrement())
// survey Survey @relation(fields: [surveyGuildId, surveyName], references: [guildId, name])
// surveyGuildId String @db.VarChar(19)
// surveyName String
// @@map("survey_questions")
// }
// model SurveyQuestionAnswer {
// content String @db.Text
// id Int @id @default(autoincrement())
// surveyResponse SurveyResponse @relation(fields: [surveyResponseId], references: [id])
// surveyResponseId Int
// question SurveyQuestion @relation(fields: [questionId], references: [id])
// questionId Int
// @@map("survey_answers")
// }
2022-03-23 00:05:22 +02:00
2022-03-22 01:28:20 +02:00
model Tag {
content String @db.Text
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
2022-04-20 02:31:56 +03:00
id Int @id @default(autoincrement())
2022-03-22 01:28:20 +02:00
name String
@@unique([guildId, name])
@@map("tags")
}
model Ticket {
2022-03-23 00:05:22 +02:00
archivedChannels ArchivedChannel[]
archivedMessages ArchivedMessage[]
archivedRoles ArchivedRole[]
archivedUsers ArchivedUser[]
category Category @relation(fields: [categoryId], references: [id])
categoryId String @db.VarChar(19)
2022-04-16 18:43:22 +03:00
claimedBy User @relation(name: "TicketsClaimedByUser", fields: [claimedById], references: [id])
2022-03-23 00:05:22 +02:00
claimedById String @db.VarChar(19)
2022-04-16 18:43:22 +03:00
closedBy User @relation(name: "TicketsClosedByUser", fields: [closedById], references: [id])
2022-03-23 00:05:22 +02:00
closedById String @db.VarChar(19)
closedReason String?
2022-04-16 18:43:22 +03:00
createdBy User @relation(name: "TicketsCreatedByUser", fields: [createdById], references: [id])
2022-03-23 00:05:22 +02:00
createdById String @db.VarChar(19)
firstResponse DateTime?
guild Guild @relation(fields: [guildId], references: [id])
guildId String @db.VarChar(19)
id String @id @unique @db.VarChar(19)
lastMessage DateTime?
number Int
open Boolean @default(true)
openingMessage String @db.VarChar(19)
pinnedMessages Json @default("[]")
2022-04-16 18:43:22 +03:00
referencedBy Ticket[] @relation("TicketsReferencedByTicket")
references Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesId], references: [id])
referencesId String? @db.VarChar(19)
2022-03-23 00:05:22 +02:00
topic String?
2022-03-22 01:28:20 +02:00
@@unique([guildId, number])
@@map("tickets")
}
model User {
2022-04-20 02:31:56 +03:00
id String @id @unique @db.VarChar(19)
2022-04-16 16:33:46 +03:00
// surveyResponses SurveyResponse[]
2022-04-16 18:43:22 +03:00
ticketsCreated Ticket[] @relation("TicketsCreatedByUser")
ticketsClosed Ticket[] @relation("TicketsClosedByUser")
ticketsClaimed Ticket[] @relation("TicketsClaimedByUser")
2022-03-22 01:28:20 +02:00
@@map("users")
}