From 05fccc79952c610f58ac76fca37d216deda74381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Sun, 26 May 2024 21:54:34 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20Database=20error=20by=20d?= =?UTF-8?q?eleting=20information=20and=20creating=20new=20relations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/tickets/src/entity/Guild.entry.ts | 4 ++++ plugins/tickets/src/entity/Template.entry.ts | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/tickets/src/entity/Guild.entry.ts b/plugins/tickets/src/entity/Guild.entry.ts index f94874f6..9a23184b 100644 --- a/plugins/tickets/src/entity/Guild.entry.ts +++ b/plugins/tickets/src/entity/Guild.entry.ts @@ -1,6 +1,7 @@ import { BaseEntity, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; import Ticket from "./Ticket.entry"; import Config from "./Config.entry"; +import Template from "./Template.entry"; @Entity({ name: 'guild_tickets' }) export default class Guild extends BaseEntity { @@ -10,6 +11,9 @@ export default class Guild extends BaseEntity { @OneToMany(() => Ticket, (ticket) => ticket.guild, { cascade: true }) tickets!: Ticket[] + @OneToMany(() => Template, (ticket) => ticket.guild, { cascade: true }) + templates!: Template[] + @OneToOne(() => Config, (config) => config.guild, { cascade: true }) @JoinColumn() configs!: Config diff --git a/plugins/tickets/src/entity/Template.entry.ts b/plugins/tickets/src/entity/Template.entry.ts index 11b9f427..68579fec 100644 --- a/plugins/tickets/src/entity/Template.entry.ts +++ b/plugins/tickets/src/entity/Template.entry.ts @@ -1,5 +1,6 @@ import { APIEmbed } from "discord.js"; -import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "typeorm"; +import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; +import Guild from "./Guild.entry"; interface Properties { [key: string]: boolean | string @@ -27,6 +28,9 @@ export default class Template extends BaseEntity { @PrimaryGeneratedColumn() id!: number + @ManyToOne(() => Guild, (guild) => guild.templates) + guild!: Guild + @Column({ type: 'text' }) messageId!: string @@ -40,7 +44,7 @@ export default class Template extends BaseEntity { }) type!: TypeTemplate - @Column('json', { + @Column('simple-json', { nullable: true, transformer: { to(value: string): string { @@ -53,7 +57,8 @@ export default class Template extends BaseEntity { }) selects!: Select[] - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value) @@ -65,7 +70,8 @@ export default class Template extends BaseEntity { }) categories!: Category[] - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value) @@ -77,7 +83,8 @@ export default class Template extends BaseEntity { }) embed!: APIEmbed - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value)