From ed28de95a5742ae590f31121fffa78b4f7db4d66 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:33:32 +0200 Subject: [PATCH 1/3] Add utf8mb4 "engine" property to all entitys --- src/util/entities/Application.ts | 8 ++++---- src/util/entities/Attachment.ts | 8 ++++---- src/util/entities/AuditLog.ts | 8 ++++---- src/util/entities/BackupCodes.ts | 8 ++++---- src/util/entities/Badge.ts | 8 ++++---- src/util/entities/Ban.ts | 8 ++++---- src/util/entities/Categories.ts | 2 +- src/util/entities/Channel.ts | 2 +- src/util/entities/ClientRelease.ts | 8 ++++---- src/util/entities/Config.ts | 8 ++++---- src/util/entities/ConnectedAccount.ts | 8 ++++---- src/util/entities/ConnectionConfigEntity.ts | 8 ++++---- src/util/entities/EmbedCache.ts | 8 ++++---- src/util/entities/Emoji.ts | 8 ++++---- src/util/entities/Encryption.ts | 8 ++++---- src/util/entities/Guild.ts | 8 ++++---- src/util/entities/Invite.ts | 8 ++++---- src/util/entities/Member.ts | 2 +- src/util/entities/Message.ts | 2 +- src/util/entities/Migration.ts | 8 ++++---- src/util/entities/Note.ts | 8 ++++---- src/util/entities/RateLimit.ts | 8 ++++---- src/util/entities/ReadState.ts | 8 ++++---- src/util/entities/Recipient.ts | 8 ++++---- src/util/entities/Relationship.ts | 8 ++++---- src/util/entities/Role.ts | 8 ++++---- src/util/entities/SecurityKey.ts | 8 ++++---- src/util/entities/Session.ts | 2 +- src/util/entities/Sticker.ts | 8 ++++---- src/util/entities/StickerPack.ts | 8 ++++---- src/util/entities/Team.ts | 8 ++++---- src/util/entities/TeamMember.ts | 8 ++++---- src/util/entities/Template.ts | 8 ++++---- src/util/entities/User.ts | 2 +- src/util/entities/UserSettings.ts | 8 ++++---- src/util/entities/ValidRegistrationTokens.ts | 8 ++++---- src/util/entities/VoiceState.ts | 8 ++++---- src/util/entities/Webhook.ts | 2 +- 38 files changed, 131 insertions(+), 131 deletions(-) diff --git a/src/util/entities/Application.ts b/src/util/entities/Application.ts index 962b2a8eb..1ecd44752 100644 --- a/src/util/entities/Application.ts +++ b/src/util/entities/Application.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { BaseClass } from "./BaseClass"; import { Team } from "./Team"; import { User } from "./User"; -@Entity("applications") +@Entity({name: "applications", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Application extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts index d60ac41cb..68d8aa54d 100644 --- a/src/util/entities/Attachment.ts +++ b/src/util/entities/Attachment.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -28,7 +28,7 @@ import { URL } from "url"; import { deleteFile } from "../util/cdn"; import { BaseClass } from "./BaseClass"; -@Entity("attachments") +@Entity({name: "attachments", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Attachment extends BaseClass { @Column() filename: string; // name of file attached diff --git a/src/util/entities/AuditLog.ts b/src/util/entities/AuditLog.ts index b375f771b..6ac2802bf 100644 --- a/src/util/entities/AuditLog.ts +++ b/src/util/entities/AuditLog.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -111,7 +111,7 @@ export enum AuditLogEvents { ROUTE_UPDATE = 226, } -@Entity("audit_logs") +@Entity({name: "audit_logs", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class AuditLog extends BaseClass { @JoinColumn({ name: "target_id" }) @ManyToOne(() => User) diff --git a/src/util/entities/BackupCodes.ts b/src/util/entities/BackupCodes.ts index 61e8f12ae..638bcd043 100644 --- a/src/util/entities/BackupCodes.ts +++ b/src/util/entities/BackupCodes.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { BaseClass } from "./BaseClass"; import { User } from "./User"; import crypto from "crypto"; -@Entity("backup_codes") +@Entity({name: "backup_codes", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class BackupCode extends BaseClass { @JoinColumn({ name: "user_id" }) @ManyToOne(() => User, { onDelete: "CASCADE" }) diff --git a/src/util/entities/Badge.ts b/src/util/entities/Badge.ts index 9535e207b..d403c6555 100644 --- a/src/util/entities/Badge.ts +++ b/src/util/entities/Badge.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; -@Entity("badges") +@Entity({name: "badges", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Badge extends BaseClassWithoutId { @Column({ primary: true }) id: string; diff --git a/src/util/entities/Ban.ts b/src/util/entities/Ban.ts index 1693cd403..2535f3e36 100644 --- a/src/util/entities/Ban.ts +++ b/src/util/entities/Ban.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; -@Entity("bans") +@Entity({name: "bans", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Ban extends BaseClass { @Column({ nullable: true }) @RelationId((ban: Ban) => ban.user) diff --git a/src/util/entities/Categories.ts b/src/util/entities/Categories.ts index 13d969dee..d3eada5a6 100644 --- a/src/util/entities/Categories.ts +++ b/src/util/entities/Categories.ts @@ -33,7 +33,7 @@ import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; // }] // Also populate discord default categories -@Entity("categories") +@Entity({name: "categories", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Categories extends BaseClassWithoutId { // Not using snowflake diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 71ccf49e1..e3856e8dd 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -69,7 +69,7 @@ export enum ChannelType { UNHANDLED = 255, // unhandled unowned pass-through channel type } -@Entity("channels") +@Entity({name: "channels", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Channel extends BaseClass { @Column() created_at: Date; diff --git a/src/util/entities/ClientRelease.ts b/src/util/entities/ClientRelease.ts index cfbc3a9b2..2282b1ff7 100644 --- a/src/util/entities/ClientRelease.ts +++ b/src/util/entities/ClientRelease.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity("client_release") +@Entity({name: "client_release", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Release extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Config.ts b/src/util/entities/Config.ts index 3c436ff09..efe8c5636 100644 --- a/src/util/entities/Config.ts +++ b/src/util/entities/Config.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; -@Entity("config") +@Entity({name: "config", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class ConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() key: string; diff --git a/src/util/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts index 6e089de16..78dec4325 100644 --- a/src/util/entities/ConnectedAccount.ts +++ b/src/util/entities/ConnectedAccount.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -26,7 +26,7 @@ export type PublicConnectedAccount = Pick< "name" | "type" | "verified" >; -@Entity("connected_accounts") +@Entity({name: "connected_accounts", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class ConnectedAccount extends BaseClass { @Column() external_id: string; diff --git a/src/util/entities/ConnectionConfigEntity.ts b/src/util/entities/ConnectionConfigEntity.ts index e4b7cea8e..0c367c1ce 100644 --- a/src/util/entities/ConnectionConfigEntity.ts +++ b/src/util/entities/ConnectionConfigEntity.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; -@Entity("connection_config") +@Entity({name: "connection_config", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class ConnectionConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() key: string; diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts index 8ff2a4577..f2dcd8931 100644 --- a/src/util/entities/EmbedCache.ts +++ b/src/util/entities/EmbedCache.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -20,7 +20,7 @@ import { BaseClass } from "./BaseClass"; import { Entity, Column } from "typeorm"; import { Embed } from "./Message"; -@Entity("embed_cache") +@Entity({name: "embed_cache", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class EmbedCache extends BaseClass { @Column() url: string; diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts index 4d851698f..65d54d5ed 100644 --- a/src/util/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { User } from "."; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; -@Entity("emojis") +@Entity({name: "emojis", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Emoji extends BaseClass { @Column() animated: boolean; diff --git a/src/util/entities/Encryption.ts b/src/util/entities/Encryption.ts index 8325bdee0..97f9052c0 100644 --- a/src/util/entities/Encryption.ts +++ b/src/util/entities/Encryption.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity("security_settings") +@Entity({name: "security_settings", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class SecuritySettings extends BaseClass { @Column({ nullable: true }) guild_id: string; diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts index fcd6b7297..7a918220f 100644 --- a/src/util/entities/Guild.ts +++ b/src/util/entities/Guild.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -66,7 +66,7 @@ export const PublicGuildRelations = [ // "members.user", ]; -@Entity("guilds") +@Entity({name: "guilds", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Guild extends BaseClass { @Column({ nullable: true }) @RelationId((guild: Guild) => guild.afk_channel) diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index f7e54fbe8..a7b17a8ac 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -25,7 +25,7 @@ import { User } from "./User"; export const PublicInviteRelation = ["inviter", "guild", "channel"]; -@Entity("invites") +@Entity({name: "invites", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Invite extends BaseClassWithoutId { @PrimaryIdColumn() code: string; diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 3ef778ace..f43d5a929 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -65,7 +65,7 @@ export const MemberPrivateProjection: (keyof Member)[] = [ "user", ]; -@Entity("members") +@Entity({name: "members", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) @Index(["id", "guild_id"], { unique: true }) export class Member extends BaseClassWithoutId { @PrimaryGeneratedColumn() diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index 1dd89dc17..f340bbc0d 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -68,7 +68,7 @@ export enum MessageType { UNHANDLED = 255, } -@Entity("messages") +@Entity({name: "messages", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) @Index(["channel_id", "id"], { unique: true }) export class Message extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Migration.ts b/src/util/entities/Migration.ts index 5c4e951d0..742e36217 100644 --- a/src/util/entities/Migration.ts +++ b/src/util/entities/Migration.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -30,7 +30,7 @@ export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith( ? ObjectIdColumn : PrimaryGeneratedColumn; -@Entity("migrations") +@Entity({name: "migrations", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Migration extends BaseEntity { @PrimaryIdAutoGenerated() id: number; diff --git a/src/util/entities/Note.ts b/src/util/entities/Note.ts index 196f68614..d220367fb 100644 --- a/src/util/entities/Note.ts +++ b/src/util/entities/Note.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -20,7 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; -@Entity("notes") +@Entity({name: "notes", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) @Unique(["owner", "target"]) export class Note extends BaseClass { @JoinColumn({ name: "owner_id" }) diff --git a/src/util/entities/RateLimit.ts b/src/util/entities/RateLimit.ts index 8d00f59ad..836a8af56 100644 --- a/src/util/entities/RateLimit.ts +++ b/src/util/entities/RateLimit.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity("rate_limits") +@Entity({name: "rate_limits", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class RateLimit extends BaseClass { @Column() // no relation as it also executor_id: string; diff --git a/src/util/entities/ReadState.ts b/src/util/entities/ReadState.ts index 1b280d128..7d367ecca 100644 --- a/src/util/entities/ReadState.ts +++ b/src/util/entities/ReadState.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -32,7 +32,7 @@ import { User } from "./User"; // notification cursor and public read receipt need to be forwards-only (the former to prevent re-pinging when marked as unread, and the latter to be acceptable as a legal acknowledgement in criminal proceedings), and private read marker needs to be advance-rewind capable // public read receipt ≥ notification cursor ≥ private fully read marker -@Entity("read_states") +@Entity({name: "read_states", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) @Index(["channel_id", "user_id"], { unique: true }) export class ReadState extends BaseClass { @Column() diff --git a/src/util/entities/Recipient.ts b/src/util/entities/Recipient.ts index 797349e58..5e2cd800d 100644 --- a/src/util/entities/Recipient.ts +++ b/src/util/entities/Recipient.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity("recipients") +@Entity({name: "recipients", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Recipient extends BaseClass { @Column() @RelationId((recipient: Recipient) => recipient.channel) diff --git a/src/util/entities/Relationship.ts b/src/util/entities/Relationship.ts index 740095c26..6472aaa1a 100644 --- a/src/util/entities/Relationship.ts +++ b/src/util/entities/Relationship.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -34,7 +34,7 @@ export enum RelationshipType { friends = 1, } -@Entity("relationships") +@Entity({name: "relationships", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) @Index(["from_id", "to_id"], { unique: true }) export class Relationship extends BaseClass { @Column({}) diff --git a/src/util/entities/Role.ts b/src/util/entities/Role.ts index 2783a2790..8a752047a 100644 --- a/src/util/entities/Role.ts +++ b/src/util/entities/Role.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; -@Entity("roles") +@Entity({name: "roles", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Role extends BaseClass { @Column() @RelationId((role: Role) => role.guild) diff --git a/src/util/entities/SecurityKey.ts b/src/util/entities/SecurityKey.ts index fd7a4c5e3..652bbb391 100644 --- a/src/util/entities/SecurityKey.ts +++ b/src/util/entities/SecurityKey.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -20,7 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; -@Entity("security_keys") +@Entity({name: "security_keys", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class SecurityKey extends BaseClass { @Column({ nullable: true }) @RelationId((key: SecurityKey) => key.user) diff --git a/src/util/entities/Session.ts b/src/util/entities/Session.ts index 15f8faa2f..1fbdd2bbc 100644 --- a/src/util/entities/Session.ts +++ b/src/util/entities/Session.ts @@ -24,7 +24,7 @@ import { Activity } from "../interfaces/Activity"; //TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them -@Entity("sessions") +@Entity({name: "sessions", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Session extends BaseClass { @Column({ nullable: true }) @RelationId((session: Session) => session.user) diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts index e9294f921..95eeb32af 100644 --- a/src/util/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -33,7 +33,7 @@ export enum StickerFormatType { LOTTIE = 3, } -@Entity("stickers") +@Entity({name: "stickers", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Sticker extends BaseClass { @Column() name: string; diff --git a/src/util/entities/StickerPack.ts b/src/util/entities/StickerPack.ts index 61ab12877..257fb6e45 100644 --- a/src/util/entities/StickerPack.ts +++ b/src/util/entities/StickerPack.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -27,7 +27,7 @@ import { import { Sticker } from "."; import { BaseClass } from "./BaseClass"; -@Entity("sticker_packs") +@Entity({name: "sticker_packs", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class StickerPack extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts index 7bedc4af0..e98344c8b 100644 --- a/src/util/entities/Team.ts +++ b/src/util/entities/Team.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -28,7 +28,7 @@ import { BaseClass } from "./BaseClass"; import { TeamMember } from "./TeamMember"; import { User } from "./User"; -@Entity("teams") +@Entity({name: "teams", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Team extends BaseClass { @Column({ nullable: true }) icon?: string; diff --git a/src/util/entities/TeamMember.ts b/src/util/entities/TeamMember.ts index 539da9576..54c90a5a6 100644 --- a/src/util/entities/TeamMember.ts +++ b/src/util/entities/TeamMember.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -25,7 +25,7 @@ export enum TeamMemberState { ACCEPTED = 2, } -@Entity("team_members") +@Entity({name: "team_members", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class TeamMember extends BaseClass { @Column({ type: "int" }) membership_state: TeamMemberState; diff --git a/src/util/entities/Template.ts b/src/util/entities/Template.ts index c417f1f08..4cf98651b 100644 --- a/src/util/entities/Template.ts +++ b/src/util/entities/Template.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -21,7 +21,7 @@ import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; -@Entity("templates") +@Entity({name: "templates", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Template extends BaseClass { @Column({ unique: true }) code: string; diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index b299bcfce..e2290d0ba 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -86,7 +86,7 @@ export interface UserPrivate extends Pick { locale: string; } -@Entity("users") +@Entity({name: "users", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class User extends BaseClass { @Column() username: string; // username max length 32, min 2 (should be configurable) diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts index d3efe79b2..0df2ff861 100644 --- a/src/util/entities/UserSettings.ts +++ b/src/util/entities/UserSettings.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -19,7 +19,7 @@ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; -@Entity("user_settings") +@Entity({name: "user_settings", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class UserSettings extends BaseClassWithoutId { @PrimaryGeneratedColumn() index: string; diff --git a/src/util/entities/ValidRegistrationTokens.ts b/src/util/entities/ValidRegistrationTokens.ts index 94fd1542b..77da100a9 100644 --- a/src/util/entities/ValidRegistrationTokens.ts +++ b/src/util/entities/ValidRegistrationTokens.ts @@ -1,24 +1,24 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm"; -@Entity("valid_registration_tokens") +@Entity({name: "valid_registration_tokens", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class ValidRegistrationToken extends BaseEntity { @PrimaryColumn() token: string; diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts index 84b0ca717..3678fa1ae 100644 --- a/src/util/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -24,7 +24,7 @@ import { Member } from "./Member"; import { User } from "./User"; //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex -@Entity("voice_states") +@Entity({name: "voice_states", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class VoiceState extends BaseClass { @Column({ nullable: true }) @RelationId((voice_state: VoiceState) => voice_state.guild) diff --git a/src/util/entities/Webhook.ts b/src/util/entities/Webhook.ts index 9539d6e8e..5d50333e5 100644 --- a/src/util/entities/Webhook.ts +++ b/src/util/entities/Webhook.ts @@ -29,7 +29,7 @@ export enum WebhookType { Application = 3, } -@Entity("webhooks") +@Entity({name: "webhooks", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) export class Webhook extends BaseClass { @Column({ type: "int" }) type: WebhookType; From 99c75d3ae42180d96552ed1be363f65412ebb21b Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sat, 17 Aug 2024 14:54:17 +0200 Subject: [PATCH 2/3] Run prettier for @Entity() --- src/util/entities/Application.ts | 5 ++++- src/util/entities/Attachment.ts | 5 ++++- src/util/entities/AuditLog.ts | 5 ++++- src/util/entities/BackupCodes.ts | 5 ++++- src/util/entities/Badge.ts | 5 ++++- src/util/entities/Ban.ts | 5 ++++- src/util/entities/Categories.ts | 5 ++++- src/util/entities/Channel.ts | 5 ++++- src/util/entities/ClientRelease.ts | 5 ++++- src/util/entities/Config.ts | 5 ++++- src/util/entities/ConnectedAccount.ts | 5 ++++- src/util/entities/ConnectionConfigEntity.ts | 5 ++++- src/util/entities/EmbedCache.ts | 5 ++++- src/util/entities/Emoji.ts | 5 ++++- src/util/entities/Encryption.ts | 5 ++++- src/util/entities/Guild.ts | 5 ++++- src/util/entities/Invite.ts | 5 ++++- src/util/entities/Member.ts | 5 ++++- src/util/entities/Message.ts | 5 ++++- src/util/entities/Migration.ts | 5 ++++- src/util/entities/Note.ts | 5 ++++- src/util/entities/RateLimit.ts | 5 ++++- src/util/entities/ReadState.ts | 5 ++++- src/util/entities/Recipient.ts | 5 ++++- src/util/entities/Relationship.ts | 5 ++++- src/util/entities/Role.ts | 5 ++++- src/util/entities/SecurityKey.ts | 5 ++++- src/util/entities/Session.ts | 5 ++++- src/util/entities/Sticker.ts | 5 ++++- src/util/entities/StickerPack.ts | 5 ++++- src/util/entities/Team.ts | 5 ++++- src/util/entities/TeamMember.ts | 5 ++++- src/util/entities/Template.ts | 5 ++++- src/util/entities/User.ts | 5 ++++- src/util/entities/UserSettings.ts | 5 ++++- src/util/entities/ValidRegistrationTokens.ts | 5 ++++- src/util/entities/VoiceState.ts | 5 ++++- src/util/entities/Webhook.ts | 5 ++++- 38 files changed, 152 insertions(+), 38 deletions(-) diff --git a/src/util/entities/Application.ts b/src/util/entities/Application.ts index 1ecd44752..c60a65476 100644 --- a/src/util/entities/Application.ts +++ b/src/util/entities/Application.ts @@ -21,7 +21,10 @@ import { BaseClass } from "./BaseClass"; import { Team } from "./Team"; import { User } from "./User"; -@Entity({name: "applications", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "applications", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Application extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts index 68d8aa54d..f5124154b 100644 --- a/src/util/entities/Attachment.ts +++ b/src/util/entities/Attachment.ts @@ -28,7 +28,10 @@ import { URL } from "url"; import { deleteFile } from "../util/cdn"; import { BaseClass } from "./BaseClass"; -@Entity({name: "attachments", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "attachments", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Attachment extends BaseClass { @Column() filename: string; // name of file attached diff --git a/src/util/entities/AuditLog.ts b/src/util/entities/AuditLog.ts index 6ac2802bf..b8a02d75a 100644 --- a/src/util/entities/AuditLog.ts +++ b/src/util/entities/AuditLog.ts @@ -111,7 +111,10 @@ export enum AuditLogEvents { ROUTE_UPDATE = 226, } -@Entity({name: "audit_logs", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "audit_logs", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class AuditLog extends BaseClass { @JoinColumn({ name: "target_id" }) @ManyToOne(() => User) diff --git a/src/util/entities/BackupCodes.ts b/src/util/entities/BackupCodes.ts index 638bcd043..b4c6f3952 100644 --- a/src/util/entities/BackupCodes.ts +++ b/src/util/entities/BackupCodes.ts @@ -21,7 +21,10 @@ import { BaseClass } from "./BaseClass"; import { User } from "./User"; import crypto from "crypto"; -@Entity({name: "backup_codes", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "backup_codes", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class BackupCode extends BaseClass { @JoinColumn({ name: "user_id" }) @ManyToOne(() => User, { onDelete: "CASCADE" }) diff --git a/src/util/entities/Badge.ts b/src/util/entities/Badge.ts index d403c6555..e716525a4 100644 --- a/src/util/entities/Badge.ts +++ b/src/util/entities/Badge.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; -@Entity({name: "badges", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "badges", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Badge extends BaseClassWithoutId { @Column({ primary: true }) id: string; diff --git a/src/util/entities/Ban.ts b/src/util/entities/Ban.ts index 2535f3e36..407569fc5 100644 --- a/src/util/entities/Ban.ts +++ b/src/util/entities/Ban.ts @@ -21,7 +21,10 @@ import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; -@Entity({name: "bans", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "bans", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Ban extends BaseClass { @Column({ nullable: true }) @RelationId((ban: Ban) => ban.user) diff --git a/src/util/entities/Categories.ts b/src/util/entities/Categories.ts index d3eada5a6..9fa643351 100644 --- a/src/util/entities/Categories.ts +++ b/src/util/entities/Categories.ts @@ -33,7 +33,10 @@ import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; // }] // Also populate discord default categories -@Entity({name: "categories", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "categories", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Categories extends BaseClassWithoutId { // Not using snowflake diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index e3856e8dd..66eaa0eb0 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -69,7 +69,10 @@ export enum ChannelType { UNHANDLED = 255, // unhandled unowned pass-through channel type } -@Entity({name: "channels", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "channels", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Channel extends BaseClass { @Column() created_at: Date; diff --git a/src/util/entities/ClientRelease.ts b/src/util/entities/ClientRelease.ts index 2282b1ff7..f6577b2c9 100644 --- a/src/util/entities/ClientRelease.ts +++ b/src/util/entities/ClientRelease.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity({name: "client_release", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "client_release", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Release extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Config.ts b/src/util/entities/Config.ts index efe8c5636..9a3fd55e3 100644 --- a/src/util/entities/Config.ts +++ b/src/util/entities/Config.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; -@Entity({name: "config", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "config", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class ConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() key: string; diff --git a/src/util/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts index 78dec4325..f0ee62fe3 100644 --- a/src/util/entities/ConnectedAccount.ts +++ b/src/util/entities/ConnectedAccount.ts @@ -26,7 +26,10 @@ export type PublicConnectedAccount = Pick< "name" | "type" | "verified" >; -@Entity({name: "connected_accounts", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "connected_accounts", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class ConnectedAccount extends BaseClass { @Column() external_id: string; diff --git a/src/util/entities/ConnectionConfigEntity.ts b/src/util/entities/ConnectionConfigEntity.ts index 0c367c1ce..19d11627a 100644 --- a/src/util/entities/ConnectionConfigEntity.ts +++ b/src/util/entities/ConnectionConfigEntity.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; -@Entity({name: "connection_config", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "connection_config", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class ConnectionConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() key: string; diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts index f2dcd8931..853fa73de 100644 --- a/src/util/entities/EmbedCache.ts +++ b/src/util/entities/EmbedCache.ts @@ -20,7 +20,10 @@ import { BaseClass } from "./BaseClass"; import { Entity, Column } from "typeorm"; import { Embed } from "./Message"; -@Entity({name: "embed_cache", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "embed_cache", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class EmbedCache extends BaseClass { @Column() url: string; diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts index 65d54d5ed..ac44b8f77 100644 --- a/src/util/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts @@ -21,7 +21,10 @@ import { User } from "."; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; -@Entity({name: "emojis", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "emojis", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Emoji extends BaseClass { @Column() animated: boolean; diff --git a/src/util/entities/Encryption.ts b/src/util/entities/Encryption.ts index 97f9052c0..3ef933fb8 100644 --- a/src/util/entities/Encryption.ts +++ b/src/util/entities/Encryption.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity({name: "security_settings", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "security_settings", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class SecuritySettings extends BaseClass { @Column({ nullable: true }) guild_id: string; diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts index 7a918220f..8517ca367 100644 --- a/src/util/entities/Guild.ts +++ b/src/util/entities/Guild.ts @@ -66,7 +66,10 @@ export const PublicGuildRelations = [ // "members.user", ]; -@Entity({name: "guilds", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "guilds", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Guild extends BaseClass { @Column({ nullable: true }) @RelationId((guild: Guild) => guild.afk_channel) diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index a7b17a8ac..6ab75302e 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -25,7 +25,10 @@ import { User } from "./User"; export const PublicInviteRelation = ["inviter", "guild", "channel"]; -@Entity({name: "invites", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "invites", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Invite extends BaseClassWithoutId { @PrimaryIdColumn() code: string; diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index f43d5a929..0ca1a15bd 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -65,7 +65,10 @@ export const MemberPrivateProjection: (keyof Member)[] = [ "user", ]; -@Entity({name: "members", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "members", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) @Index(["id", "guild_id"], { unique: true }) export class Member extends BaseClassWithoutId { @PrimaryGeneratedColumn() diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index f340bbc0d..ba6b1ac76 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -68,7 +68,10 @@ export enum MessageType { UNHANDLED = 255, } -@Entity({name: "messages", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "messages", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) @Index(["channel_id", "id"], { unique: true }) export class Message extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Migration.ts b/src/util/entities/Migration.ts index 742e36217..cd572c03f 100644 --- a/src/util/entities/Migration.ts +++ b/src/util/entities/Migration.ts @@ -30,7 +30,10 @@ export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith( ? ObjectIdColumn : PrimaryGeneratedColumn; -@Entity({name: "migrations", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "migrations", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Migration extends BaseEntity { @PrimaryIdAutoGenerated() id: number; diff --git a/src/util/entities/Note.ts b/src/util/entities/Note.ts index d220367fb..4821d2d91 100644 --- a/src/util/entities/Note.ts +++ b/src/util/entities/Note.ts @@ -20,7 +20,10 @@ import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; -@Entity({name: "notes", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "notes", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) @Unique(["owner", "target"]) export class Note extends BaseClass { @JoinColumn({ name: "owner_id" }) diff --git a/src/util/entities/RateLimit.ts b/src/util/entities/RateLimit.ts index 836a8af56..f0f597e00 100644 --- a/src/util/entities/RateLimit.ts +++ b/src/util/entities/RateLimit.ts @@ -19,7 +19,10 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity({name: "rate_limits", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "rate_limits", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class RateLimit extends BaseClass { @Column() // no relation as it also executor_id: string; diff --git a/src/util/entities/ReadState.ts b/src/util/entities/ReadState.ts index 7d367ecca..8e555de63 100644 --- a/src/util/entities/ReadState.ts +++ b/src/util/entities/ReadState.ts @@ -32,7 +32,10 @@ import { User } from "./User"; // notification cursor and public read receipt need to be forwards-only (the former to prevent re-pinging when marked as unread, and the latter to be acceptable as a legal acknowledgement in criminal proceedings), and private read marker needs to be advance-rewind capable // public read receipt ≥ notification cursor ≥ private fully read marker -@Entity({name: "read_states", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "read_states", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) @Index(["channel_id", "user_id"], { unique: true }) export class ReadState extends BaseClass { @Column() diff --git a/src/util/entities/Recipient.ts b/src/util/entities/Recipient.ts index 5e2cd800d..fecb051f2 100644 --- a/src/util/entities/Recipient.ts +++ b/src/util/entities/Recipient.ts @@ -19,7 +19,10 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; -@Entity({name: "recipients", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "recipients", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Recipient extends BaseClass { @Column() @RelationId((recipient: Recipient) => recipient.channel) diff --git a/src/util/entities/Relationship.ts b/src/util/entities/Relationship.ts index 6472aaa1a..3aa057e7f 100644 --- a/src/util/entities/Relationship.ts +++ b/src/util/entities/Relationship.ts @@ -34,7 +34,10 @@ export enum RelationshipType { friends = 1, } -@Entity({name: "relationships", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "relationships", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) @Index(["from_id", "to_id"], { unique: true }) export class Relationship extends BaseClass { @Column({}) diff --git a/src/util/entities/Role.ts b/src/util/entities/Role.ts index 8a752047a..f45098277 100644 --- a/src/util/entities/Role.ts +++ b/src/util/entities/Role.ts @@ -21,7 +21,10 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; -@Entity({name: "roles", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "roles", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Role extends BaseClass { @Column() @RelationId((role: Role) => role.guild) diff --git a/src/util/entities/SecurityKey.ts b/src/util/entities/SecurityKey.ts index 652bbb391..f0b156c92 100644 --- a/src/util/entities/SecurityKey.ts +++ b/src/util/entities/SecurityKey.ts @@ -20,7 +20,10 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; -@Entity({name: "security_keys", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "security_keys", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class SecurityKey extends BaseClass { @Column({ nullable: true }) @RelationId((key: SecurityKey) => key.user) diff --git a/src/util/entities/Session.ts b/src/util/entities/Session.ts index 1fbdd2bbc..b7657d979 100644 --- a/src/util/entities/Session.ts +++ b/src/util/entities/Session.ts @@ -24,7 +24,10 @@ import { Activity } from "../interfaces/Activity"; //TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them -@Entity({name: "sessions", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "sessions", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Session extends BaseClass { @Column({ nullable: true }) @RelationId((session: Session) => session.user) diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts index 95eeb32af..5b17c9b88 100644 --- a/src/util/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts @@ -33,7 +33,10 @@ export enum StickerFormatType { LOTTIE = 3, } -@Entity({name: "stickers", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "stickers", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Sticker extends BaseClass { @Column() name: string; diff --git a/src/util/entities/StickerPack.ts b/src/util/entities/StickerPack.ts index 257fb6e45..5f7bf671f 100644 --- a/src/util/entities/StickerPack.ts +++ b/src/util/entities/StickerPack.ts @@ -27,7 +27,10 @@ import { import { Sticker } from "."; import { BaseClass } from "./BaseClass"; -@Entity({name: "sticker_packs", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "sticker_packs", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class StickerPack extends BaseClass { @Column() name: string; diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts index e98344c8b..7c804260e 100644 --- a/src/util/entities/Team.ts +++ b/src/util/entities/Team.ts @@ -28,7 +28,10 @@ import { BaseClass } from "./BaseClass"; import { TeamMember } from "./TeamMember"; import { User } from "./User"; -@Entity({name: "teams", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "teams", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Team extends BaseClass { @Column({ nullable: true }) icon?: string; diff --git a/src/util/entities/TeamMember.ts b/src/util/entities/TeamMember.ts index 54c90a5a6..5b82d30e3 100644 --- a/src/util/entities/TeamMember.ts +++ b/src/util/entities/TeamMember.ts @@ -25,7 +25,10 @@ export enum TeamMemberState { ACCEPTED = 2, } -@Entity({name: "team_members", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "team_members", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class TeamMember extends BaseClass { @Column({ type: "int" }) membership_state: TeamMemberState; diff --git a/src/util/entities/Template.ts b/src/util/entities/Template.ts index 4cf98651b..3d5c1764b 100644 --- a/src/util/entities/Template.ts +++ b/src/util/entities/Template.ts @@ -21,7 +21,10 @@ import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; -@Entity({name: "templates", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "templates", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Template extends BaseClass { @Column({ unique: true }) code: string; diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index e2290d0ba..43c4aea63 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -86,7 +86,10 @@ export interface UserPrivate extends Pick { locale: string; } -@Entity({name: "users", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "users", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class User extends BaseClass { @Column() username: string; // username max length 32, min 2 (should be configurable) diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts index 0df2ff861..1f27630db 100644 --- a/src/util/entities/UserSettings.ts +++ b/src/util/entities/UserSettings.ts @@ -19,7 +19,10 @@ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; -@Entity({name: "user_settings", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "user_settings", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class UserSettings extends BaseClassWithoutId { @PrimaryGeneratedColumn() index: string; diff --git a/src/util/entities/ValidRegistrationTokens.ts b/src/util/entities/ValidRegistrationTokens.ts index 77da100a9..737adfc16 100644 --- a/src/util/entities/ValidRegistrationTokens.ts +++ b/src/util/entities/ValidRegistrationTokens.ts @@ -18,7 +18,10 @@ import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm"; -@Entity({name: "valid_registration_tokens", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "valid_registration_tokens", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class ValidRegistrationToken extends BaseEntity { @PrimaryColumn() token: string; diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts index 3678fa1ae..de0a52d3b 100644 --- a/src/util/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts @@ -24,7 +24,10 @@ import { Member } from "./Member"; import { User } from "./User"; //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex -@Entity({name: "voice_states", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "voice_states", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class VoiceState extends BaseClass { @Column({ nullable: true }) @RelationId((voice_state: VoiceState) => voice_state.guild) diff --git a/src/util/entities/Webhook.ts b/src/util/entities/Webhook.ts index 5d50333e5..7005bf647 100644 --- a/src/util/entities/Webhook.ts +++ b/src/util/entities/Webhook.ts @@ -29,7 +29,10 @@ export enum WebhookType { Application = 3, } -@Entity({name: "webhooks", engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"}) +@Entity({ + name: "webhooks", + engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", +}) export class Webhook extends BaseClass { @Column({ type: "int" }) type: WebhookType; From dfbbef3637af1e3777c200d0c2b05757404dd2f5 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:58:24 +0200 Subject: [PATCH 3/3] "engine" const value shared --- src/util/entities/Application.ts | 3 ++- src/util/entities/Attachment.ts | 3 ++- src/util/entities/AuditLog.ts | 3 ++- src/util/entities/BackupCodes.ts | 3 ++- src/util/entities/Badge.ts | 3 ++- src/util/entities/Ban.ts | 3 ++- src/util/entities/Categories.ts | 3 ++- src/util/entities/Channel.ts | 3 ++- src/util/entities/ClientRelease.ts | 3 ++- src/util/entities/Config.ts | 3 ++- src/util/entities/ConnectedAccount.ts | 3 ++- src/util/entities/ConnectionConfigEntity.ts | 3 ++- src/util/entities/EmbedCache.ts | 3 ++- src/util/entities/Emoji.ts | 3 ++- src/util/entities/Encryption.ts | 3 ++- src/util/entities/Guild.ts | 3 ++- src/util/entities/Invite.ts | 3 ++- src/util/entities/Member.ts | 3 ++- src/util/entities/Message.ts | 3 ++- src/util/entities/Migration.ts | 3 ++- src/util/entities/Note.ts | 3 ++- src/util/entities/RateLimit.ts | 3 ++- src/util/entities/ReadState.ts | 3 ++- src/util/entities/Recipient.ts | 3 ++- src/util/entities/Relationship.ts | 3 ++- src/util/entities/Role.ts | 3 ++- src/util/entities/SecurityKey.ts | 3 ++- src/util/entities/Session.ts | 3 ++- src/util/entities/Sticker.ts | 3 ++- src/util/entities/StickerPack.ts | 3 ++- src/util/entities/Team.ts | 3 ++- src/util/entities/TeamMember.ts | 3 ++- src/util/entities/Template.ts | 3 ++- src/util/entities/User.ts | 3 ++- src/util/entities/UserSettings.ts | 3 ++- src/util/entities/ValidRegistrationTokens.ts | 3 ++- src/util/entities/VoiceState.ts | 3 ++- src/util/entities/Webhook.ts | 3 ++- src/util/util/Database.ts | 9 ++++++--- 39 files changed, 82 insertions(+), 41 deletions(-) diff --git a/src/util/entities/Application.ts b/src/util/entities/Application.ts index c60a65476..4ed75f275 100644 --- a/src/util/entities/Application.ts +++ b/src/util/entities/Application.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Team } from "./Team"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "applications", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Application extends BaseClass { @Column() diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts index f5124154b..e489609d3 100644 --- a/src/util/entities/Attachment.ts +++ b/src/util/entities/Attachment.ts @@ -27,10 +27,11 @@ import { import { URL } from "url"; import { deleteFile } from "../util/cdn"; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "attachments", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Attachment extends BaseClass { @Column() diff --git a/src/util/entities/AuditLog.ts b/src/util/entities/AuditLog.ts index b8a02d75a..49c836c3b 100644 --- a/src/util/entities/AuditLog.ts +++ b/src/util/entities/AuditLog.ts @@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { ChannelPermissionOverwrite } from "./Channel"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export enum AuditLogEvents { // guild level @@ -113,7 +114,7 @@ export enum AuditLogEvents { @Entity({ name: "audit_logs", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class AuditLog extends BaseClass { @JoinColumn({ name: "target_id" }) diff --git a/src/util/entities/BackupCodes.ts b/src/util/entities/BackupCodes.ts index b4c6f3952..9afc181ad 100644 --- a/src/util/entities/BackupCodes.ts +++ b/src/util/entities/BackupCodes.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; import crypto from "crypto"; +import { dbEngine } from "../util/Database"; @Entity({ name: "backup_codes", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class BackupCode extends BaseClass { @JoinColumn({ name: "user_id" }) diff --git a/src/util/entities/Badge.ts b/src/util/entities/Badge.ts index e716525a4..4b98006ae 100644 --- a/src/util/entities/Badge.ts +++ b/src/util/entities/Badge.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "badges", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Badge extends BaseClassWithoutId { @Column({ primary: true }) diff --git a/src/util/entities/Ban.ts b/src/util/entities/Ban.ts index 407569fc5..ed5f47e12 100644 --- a/src/util/entities/Ban.ts +++ b/src/util/entities/Ban.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "bans", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Ban extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Categories.ts b/src/util/entities/Categories.ts index 9fa643351..990e7fdda 100644 --- a/src/util/entities/Categories.ts +++ b/src/util/entities/Categories.ts @@ -18,6 +18,7 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; +import { dbEngine } from "../util/Database"; // TODO: categories: // [{ @@ -35,7 +36,7 @@ import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; @Entity({ name: "categories", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Categories extends BaseClassWithoutId { // Not using snowflake diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 66eaa0eb0..3b841c8f1 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -44,6 +44,7 @@ import { Recipient } from "./Recipient"; import { PublicUserProjection, User } from "./User"; import { VoiceState } from "./VoiceState"; import { Webhook } from "./Webhook"; +import { dbEngine } from "../util/Database"; export enum ChannelType { GUILD_TEXT = 0, // a text channel within a guild @@ -71,7 +72,7 @@ export enum ChannelType { @Entity({ name: "channels", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Channel extends BaseClass { @Column() diff --git a/src/util/entities/ClientRelease.ts b/src/util/entities/ClientRelease.ts index f6577b2c9..aa697939f 100644 --- a/src/util/entities/ClientRelease.ts +++ b/src/util/entities/ClientRelease.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "client_release", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Release extends BaseClass { @Column() diff --git a/src/util/entities/Config.ts b/src/util/entities/Config.ts index 9a3fd55e3..8d725a12c 100644 --- a/src/util/entities/Config.ts +++ b/src/util/entities/Config.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "config", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class ConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() diff --git a/src/util/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts index f0ee62fe3..0c9eb402f 100644 --- a/src/util/entities/ConnectedAccount.ts +++ b/src/util/entities/ConnectedAccount.ts @@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { ConnectedAccountTokenData } from "../interfaces"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export type PublicConnectedAccount = Pick< ConnectedAccount, @@ -28,7 +29,7 @@ export type PublicConnectedAccount = Pick< @Entity({ name: "connected_accounts", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class ConnectedAccount extends BaseClass { @Column() diff --git a/src/util/entities/ConnectionConfigEntity.ts b/src/util/entities/ConnectionConfigEntity.ts index 19d11627a..9d4dde60f 100644 --- a/src/util/entities/ConnectionConfigEntity.ts +++ b/src/util/entities/ConnectionConfigEntity.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "connection_config", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class ConnectionConfigEntity extends BaseClassWithoutId { @PrimaryIdColumn() diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts index 853fa73de..8d68b0ac6 100644 --- a/src/util/entities/EmbedCache.ts +++ b/src/util/entities/EmbedCache.ts @@ -19,10 +19,11 @@ import { BaseClass } from "./BaseClass"; import { Entity, Column } from "typeorm"; import { Embed } from "./Message"; +import { dbEngine } from "../util/Database"; @Entity({ name: "embed_cache", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class EmbedCache extends BaseClass { @Column() diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts index ac44b8f77..198d5faf0 100644 --- a/src/util/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { User } from "."; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; +import { dbEngine } from "../util/Database"; @Entity({ name: "emojis", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Emoji extends BaseClass { @Column() diff --git a/src/util/entities/Encryption.ts b/src/util/entities/Encryption.ts index 3ef933fb8..21e77b484 100644 --- a/src/util/entities/Encryption.ts +++ b/src/util/entities/Encryption.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "security_settings", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class SecuritySettings extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Guild.ts b/src/util/entities/Guild.ts index 8517ca367..4e49ce9b8 100644 --- a/src/util/entities/Guild.ts +++ b/src/util/entities/Guild.ts @@ -37,6 +37,7 @@ import { Template } from "./Template"; import { User } from "./User"; import { VoiceState } from "./VoiceState"; import { Webhook } from "./Webhook"; +import { dbEngine } from "../util/Database"; // TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0} // TODO: guild_scheduled_events @@ -68,7 +69,7 @@ export const PublicGuildRelations = [ @Entity({ name: "guilds", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Guild extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index 6ab75302e..e1b8cabdd 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -22,12 +22,13 @@ import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { Member } from "./Member"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export const PublicInviteRelation = ["inviter", "guild", "channel"]; @Entity({ name: "invites", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Invite extends BaseClassWithoutId { @PrimaryIdColumn() diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 0ca1a15bd..62ab9398f 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -48,6 +48,7 @@ import { Guild } from "./Guild"; import { Message } from "./Message"; import { Role } from "./Role"; import { PublicUser, User } from "./User"; +import { dbEngine } from "../util/Database"; export const MemberPrivateProjection: (keyof Member)[] = [ "id", @@ -67,7 +68,7 @@ export const MemberPrivateProjection: (keyof Member)[] = [ @Entity({ name: "members", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) @Index(["id", "guild_id"], { unique: true }) export class Member extends BaseClassWithoutId { diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index ba6b1ac76..9dc2949db 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -39,6 +39,7 @@ import { Guild } from "./Guild"; import { Webhook } from "./Webhook"; import { Sticker } from "./Sticker"; import { Attachment } from "./Attachment"; +import { dbEngine } from "../util/Database"; export enum MessageType { DEFAULT = 0, @@ -70,7 +71,7 @@ export enum MessageType { @Entity({ name: "messages", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) @Index(["channel_id", "id"], { unique: true }) export class Message extends BaseClass { diff --git a/src/util/entities/Migration.ts b/src/util/entities/Migration.ts index cd572c03f..f0ee3e075 100644 --- a/src/util/entities/Migration.ts +++ b/src/util/entities/Migration.ts @@ -23,6 +23,7 @@ import { PrimaryGeneratedColumn, BaseEntity, } from "typeorm"; +import { dbEngine } from "../util/Database"; export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith( "mongodb", @@ -32,7 +33,7 @@ export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith( @Entity({ name: "migrations", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Migration extends BaseEntity { @PrimaryIdAutoGenerated() diff --git a/src/util/entities/Note.ts b/src/util/entities/Note.ts index 4821d2d91..9773c8021 100644 --- a/src/util/entities/Note.ts +++ b/src/util/entities/Note.ts @@ -19,10 +19,11 @@ import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "notes", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) @Unique(["owner", "target"]) export class Note extends BaseClass { diff --git a/src/util/entities/RateLimit.ts b/src/util/entities/RateLimit.ts index f0f597e00..ba2b79313 100644 --- a/src/util/entities/RateLimit.ts +++ b/src/util/entities/RateLimit.ts @@ -18,10 +18,11 @@ import { Column, Entity } from "typeorm"; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "rate_limits", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class RateLimit extends BaseClass { @Column() // no relation as it also diff --git a/src/util/entities/ReadState.ts b/src/util/entities/ReadState.ts index 8e555de63..9f362547f 100644 --- a/src/util/entities/ReadState.ts +++ b/src/util/entities/ReadState.ts @@ -27,6 +27,7 @@ import { import { BaseClass } from "./BaseClass"; import { Channel } from "./Channel"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; // for read receipts // notification cursor and public read receipt need to be forwards-only (the former to prevent re-pinging when marked as unread, and the latter to be acceptable as a legal acknowledgement in criminal proceedings), and private read marker needs to be advance-rewind capable @@ -34,7 +35,7 @@ import { User } from "./User"; @Entity({ name: "read_states", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) @Index(["channel_id", "user_id"], { unique: true }) export class ReadState extends BaseClass { diff --git a/src/util/entities/Recipient.ts b/src/util/entities/Recipient.ts index fecb051f2..268962201 100644 --- a/src/util/entities/Recipient.ts +++ b/src/util/entities/Recipient.ts @@ -18,10 +18,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "recipients", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Recipient extends BaseClass { @Column() diff --git a/src/util/entities/Relationship.ts b/src/util/entities/Relationship.ts index 3aa057e7f..d8dfc289e 100644 --- a/src/util/entities/Relationship.ts +++ b/src/util/entities/Relationship.ts @@ -26,6 +26,7 @@ import { } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export enum RelationshipType { outgoing = 4, @@ -36,7 +37,7 @@ export enum RelationshipType { @Entity({ name: "relationships", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) @Index(["from_id", "to_id"], { unique: true }) export class Relationship extends BaseClass { diff --git a/src/util/entities/Role.ts b/src/util/entities/Role.ts index f45098277..c5df6068e 100644 --- a/src/util/entities/Role.ts +++ b/src/util/entities/Role.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; +import { dbEngine } from "../util/Database"; @Entity({ name: "roles", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Role extends BaseClass { @Column() diff --git a/src/util/entities/SecurityKey.ts b/src/util/entities/SecurityKey.ts index f0b156c92..efe46c81f 100644 --- a/src/util/entities/SecurityKey.ts +++ b/src/util/entities/SecurityKey.ts @@ -19,10 +19,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "security_keys", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class SecurityKey extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Session.ts b/src/util/entities/Session.ts index b7657d979..5c3d5a4fd 100644 --- a/src/util/entities/Session.ts +++ b/src/util/entities/Session.ts @@ -21,12 +21,13 @@ import { BaseClass } from "./BaseClass"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { ClientStatus, Status } from "../interfaces/Status"; import { Activity } from "../interfaces/Activity"; +import { dbEngine } from "../util/Database"; //TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them @Entity({ name: "sessions", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Session extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts index 5b17c9b88..78b6d207d 100644 --- a/src/util/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts @@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export enum StickerType { STANDARD = 1, @@ -35,7 +36,7 @@ export enum StickerFormatType { @Entity({ name: "stickers", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Sticker extends BaseClass { @Column() diff --git a/src/util/entities/StickerPack.ts b/src/util/entities/StickerPack.ts index 5f7bf671f..43d27d60b 100644 --- a/src/util/entities/StickerPack.ts +++ b/src/util/entities/StickerPack.ts @@ -26,10 +26,11 @@ import { } from "typeorm"; import { Sticker } from "."; import { BaseClass } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "sticker_packs", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class StickerPack extends BaseClass { @Column() diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts index 7c804260e..6b3fa5543 100644 --- a/src/util/entities/Team.ts +++ b/src/util/entities/Team.ts @@ -27,10 +27,11 @@ import { import { BaseClass } from "./BaseClass"; import { TeamMember } from "./TeamMember"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "teams", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Team extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/TeamMember.ts b/src/util/entities/TeamMember.ts index 5b82d30e3..2cd04710a 100644 --- a/src/util/entities/TeamMember.ts +++ b/src/util/entities/TeamMember.ts @@ -19,6 +19,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export enum TeamMemberState { INVITED = 1, @@ -27,7 +28,7 @@ export enum TeamMemberState { @Entity({ name: "team_members", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class TeamMember extends BaseClass { @Column({ type: "int" }) diff --git a/src/util/entities/Template.ts b/src/util/entities/Template.ts index 3d5c1764b..faf6454a9 100644 --- a/src/util/entities/Template.ts +++ b/src/util/entities/Template.ts @@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { BaseClass } from "./BaseClass"; import { Guild } from "./Guild"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; @Entity({ name: "templates", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Template extends BaseClass { @Column({ unique: true }) diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts index 43c4aea63..0323de528 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts @@ -34,6 +34,7 @@ import { Relationship } from "./Relationship"; import { SecurityKey } from "./SecurityKey"; import { Session } from "./Session"; import { UserSettings } from "./UserSettings"; +import { dbEngine } from "../util/Database"; export enum PublicUserEnum { username, @@ -88,7 +89,7 @@ export interface UserPrivate extends Pick { @Entity({ name: "users", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class User extends BaseClass { @Column() diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts index 1f27630db..cbb1cbcf3 100644 --- a/src/util/entities/UserSettings.ts +++ b/src/util/entities/UserSettings.ts @@ -18,10 +18,11 @@ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; import { BaseClassWithoutId } from "./BaseClass"; +import { dbEngine } from "../util/Database"; @Entity({ name: "user_settings", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class UserSettings extends BaseClassWithoutId { @PrimaryGeneratedColumn() diff --git a/src/util/entities/ValidRegistrationTokens.ts b/src/util/entities/ValidRegistrationTokens.ts index 737adfc16..709457656 100644 --- a/src/util/entities/ValidRegistrationTokens.ts +++ b/src/util/entities/ValidRegistrationTokens.ts @@ -17,10 +17,11 @@ */ import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm"; +import { dbEngine } from "../util/Database"; @Entity({ name: "valid_registration_tokens", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class ValidRegistrationToken extends BaseEntity { @PrimaryColumn() diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts index de0a52d3b..83a0af63b 100644 --- a/src/util/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts @@ -22,11 +22,12 @@ import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { Member } from "./Member"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex @Entity({ name: "voice_states", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class VoiceState extends BaseClass { @Column({ nullable: true }) diff --git a/src/util/entities/Webhook.ts b/src/util/entities/Webhook.ts index 7005bf647..473352c87 100644 --- a/src/util/entities/Webhook.ts +++ b/src/util/entities/Webhook.ts @@ -22,6 +22,7 @@ import { BaseClass } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; import { User } from "./User"; +import { dbEngine } from "../util/Database"; export enum WebhookType { Incoming = 1, @@ -31,7 +32,7 @@ export enum WebhookType { @Entity({ name: "webhooks", - engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", + engine: dbEngine, }) export class Webhook extends BaseClass { @Column({ type: "int" }) diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts index 3a45eea0e..af0960cd9 100644 --- a/src/util/util/Database.ts +++ b/src/util/util/Database.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -134,3 +134,6 @@ export { DataSourceOptions, DatabaseType, dbConnection }; export async function closeDatabase() { await dbConnection?.destroy(); } + +export const dbEngine = + "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";