Fix schema issues

This commit is contained in:
Isaac 2022-08-08 22:38:54 +01:00
parent bc3ccdcb82
commit f419cbf967
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A
7 changed files with 115 additions and 115 deletions

View File

@ -11,10 +11,11 @@ SUPER=
https://www.prisma.io/docs/reference/database-reference/supported-databases https://www.prisma.io/docs/reference/database-reference/supported-databases
![](https://static.eartharoid.me/k/22/08/02185801.png) - for user/create, slash/force-close and slash/move ![](https://static.eartharoid.me/k/22/08/02185801.png) - for user/create, slash/force-close, slash/claim, slash/release, and slash/move
menu question max length cannot be higher than question options menu question max length cannot be higher than question options
- TODO: topic and question answer values not encrypted?
- TODO: post stats - TODO: post stats
- TODO: settings bundle download - TODO: settings bundle download
- TODO: update notifications - TODO: update notifications
@ -29,4 +30,4 @@ creation requires an interaction:
- message:create(staff) -> category? -> DM (channel fallback) button -> topic or questions -> create - message:create(staff) -> category? -> DM (channel fallback) button -> topic or questions -> create
- DM -> guild? -> category? -> topic or questions -> create - DM -> guild? -> category? -> topic or questions -> create
- panel(interaction) -> topic or questions -> create - panel(interaction) -> topic or questions -> create
- panel(message) -> DM (channel fallback) button -> topic or questions -> create - ~~panel(message) -> DM (channel fallback) button -> topic or questions -> create~~

View File

@ -20,16 +20,16 @@ model ArchivedChannel {
} }
model ArchivedMessage { model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade)
authorId String @db.VarChar(19) authorId String @db.VarChar(19)
content String @db.Text content Json
createdAt DateTime @default(now()) 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) external Boolean @default(false)
referencedBy Ticket[] @relation("MessageReferencedByTicket") id String @id @db.VarChar(19)
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)
@@map("archivedMessages") @@map("archivedMessages")
} }
@ -68,30 +68,30 @@ model ArchivedUser {
} }
model Category { model Category {
channelName String channelName String
claiming Boolean @default(false) claiming Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
cooldown Int? cooldown Int?
customTopic String? customTopic String?
description String description String
discordCategory String @db.VarChar(19) discordCategory String @db.VarChar(19)
emoji String emoji String
enableFeedback Boolean @default(false) enableFeedback Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
image String? image String?
memberLimit Int @default(1) memberLimit Int @default(1)
name String name String
openingMessage String @db.Text openingMessage String @db.Text
pingRoles Json @default("[]") pingRoles Json @default("[]")
questions Question[] questions Question[]
ratelimit Int? ratelimit Int?
requiredRoles Json @default("[]") requiredRoles Json @default("[]")
requireTopic Boolean @default(false) requireTopic Boolean @default(false)
staffRoles Json staffRoles Json
tickets Ticket[] tickets Ticket[]
totalLimit Int @default(50) totalLimit Int @default(50)
@@map("categories") @@map("categories")
} }
@ -210,11 +210,10 @@ model Ticket {
messageCount Int? messageCount Int?
number Int number Int
open Boolean @default(true) open Boolean @default(true)
openingMessage String @db.VarChar(19) openingMessageId String @db.VarChar(19)
pinnedMessages Json @default("[]") pinnedMessageIds Json @default("[]")
priority TicketPriority? priority TicketPriority?
referencedBy Ticket[] @relation("TicketsReferencedByTicket") referencedBy Ticket[] @relation("TicketsReferencedByTicket")
referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull)
referencesMessageId String? @db.VarChar(19) referencesMessageId String? @db.VarChar(19)
referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull)
referencesTicketId String? @db.VarChar(19) referencesTicketId String? @db.VarChar(19)

View File

@ -20,16 +20,16 @@ model ArchivedChannel {
} }
model ArchivedMessage { model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade)
authorId String @db.VarChar(19) authorId String @db.VarChar(19)
content String @db.Text content Json
createdAt DateTime @default(now()) 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) external Boolean @default(false)
referencedBy Ticket[] @relation("MessageReferencedByTicket") id String @id @db.VarChar(19)
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)
@@map("archivedMessages") @@map("archivedMessages")
} }
@ -68,30 +68,30 @@ model ArchivedUser {
} }
model Category { model Category {
channelName String channelName String
claiming Boolean @default(false) claiming Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
cooldown Int? cooldown Int?
customTopic String? customTopic String?
description String description String
discordCategory String @db.VarChar(19) discordCategory String @db.VarChar(19)
emoji String emoji String
enableFeedback Boolean @default(false) enableFeedback Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19) guildId String @db.VarChar(19)
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
image String? image String?
memberLimit Int @default(1) memberLimit Int @default(1)
name String name String
openingMessage String @db.Text openingMessage String @db.Text
pingRoles Json @default("[]") pingRoles Json @default("[]")
questions Question[] questions Question[]
ratelimit Int? ratelimit Int?
requiredRoles Json @default("[]") requiredRoles Json @default("[]")
requireTopic Boolean @default(false) requireTopic Boolean @default(false)
staffRoles Json staffRoles Json
tickets Ticket[] tickets Ticket[]
totalLimit Int @default(50) totalLimit Int @default(50)
@@map("categories") @@map("categories")
} }
@ -210,11 +210,10 @@ model Ticket {
messageCount Int? messageCount Int?
number Int number Int
open Boolean @default(true) open Boolean @default(true)
openingMessage String @db.VarChar(19) openingMessageId String @db.VarChar(19)
pinnedMessages Json @default("[]") pinnedMessageIds Json @default("[]")
priority TicketPriority? priority TicketPriority?
referencedBy Ticket[] @relation("TicketsReferencedByTicket") referencedBy Ticket[] @relation("TicketsReferencedByTicket")
referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull)
referencesMessageId String? @db.VarChar(19) referencesMessageId String? @db.VarChar(19)
referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull)
referencesTicketId String? @db.VarChar(19) referencesTicketId String? @db.VarChar(19)

View File

@ -20,16 +20,16 @@ model ArchivedChannel {
} }
model ArchivedMessage { model ArchivedMessage {
author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade)
authorId String authorId String
content String content String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
deleted Boolean @default(false) deleted Boolean @default(false)
edited Boolean @default(false) edited Boolean @default(false)
id String @id id String @id
referencedBy Ticket[] @relation("MessageReferencedByTicket") external Boolean @default(false)
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
ticketId String ticketId String
@@map("archivedMessages") @@map("archivedMessages")
} }
@ -68,30 +68,30 @@ model ArchivedUser {
} }
model Category { model Category {
channelName String channelName String
claiming Boolean @default(false) claiming Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
cooldown Int? cooldown Int?
customTopic String? customTopic String?
description String description String
discordCategory String discordCategory String
emoji String emoji String
enableFeedback Boolean @default(false) enableFeedback Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String guildId String
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
image String? image String?
memberLimit Int @default(1) memberLimit Int @default(1)
name String name String
openingMessage String openingMessage String
pingRoles String @default("[]") pingRoles String @default("[]")
questions Question[] questions Question[]
ratelimit Int? ratelimit Int?
requiredRoles String @default("[]") requiredRoles String @default("[]")
requireTopic Boolean @default(false) requireTopic Boolean @default(false)
staffRoles String staffRoles String
tickets Ticket[] tickets Ticket[]
totalLimit Int @default(50) totalLimit Int @default(50)
@@map("categories") @@map("categories")
} }
@ -210,11 +210,10 @@ model Ticket {
messageCount Int? messageCount Int?
number Int number Int
open Boolean @default(true) open Boolean @default(true)
openingMessage String openingMessageId String
pinnedMessages String @default("[]") pinnedMessageIds String @default("[]")
priority String? priority String?
referencedBy Ticket[] @relation("TicketsReferencedByTicket") referencedBy Ticket[] @relation("TicketsReferencedByTicket")
referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull)
referencesMessageId String? referencesMessageId String?
referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull)
referencesTicketId String? referencesTicketId String?

View File

@ -6,7 +6,7 @@ const jsonFields = [
'blocklist', 'blocklist',
'workingHours', 'workingHours',
'options', 'options',
'pinnedMessages', 'pinnedMessageIds',
]; ];
const traverse = (obj, action) => { const traverse = (obj, action) => {

View File

@ -371,7 +371,7 @@ module.exports = class TicketManager {
guild: { connect: { id: category.guild.id } }, guild: { connect: { id: category.guild.id } },
id: channel.id, id: channel.id,
number, number,
openingMessage: sent.id, openingMessageId: sent.id,
topic, topic,
}; };
if (referencesTicket) data.referencesTicket = { connect: { id: referencesTicket } }; if (referencesTicket) data.referencesTicket = { connect: { id: referencesTicket } };

View File

@ -179,7 +179,9 @@ module.exports = class extends Listener {
} else { } else {
// TODO: archive messages in tickets // TODO: archive messages in tickets
// TODO: first response // TODO: first response
// TODO: lastMessageAt
// TODO: auto tag // TODO: auto tag
// TODO: staff status alert, working hours alerts
} }
} }
}; };