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

@ -22,12 +22,12 @@ 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)
external Boolean @default(false)
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
referencedBy Ticket[] @relation("MessageReferencedByTicket")
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)
@ -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

@ -22,12 +22,12 @@ 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)
external Boolean @default(false)
id String @id @db.VarChar(19) id String @id @db.VarChar(19)
referencedBy Ticket[] @relation("MessageReferencedByTicket")
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)
@ -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

@ -27,7 +27,7 @@ model ArchivedMessage {
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
@ -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
} }
} }
}; };