"engine" const value shared

This commit is contained in:
TomatoCake 2024-08-18 17:58:24 +02:00
parent 99c75d3ae4
commit dfbbef3637
39 changed files with 82 additions and 41 deletions

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Team } from "./Team"; import { Team } from "./Team";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "applications", name: "applications",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Application extends BaseClass { export class Application extends BaseClass {
@Column() @Column()

View File

@ -27,10 +27,11 @@ import {
import { URL } from "url"; import { URL } from "url";
import { deleteFile } from "../util/cdn"; import { deleteFile } from "../util/cdn";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "attachments", name: "attachments",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Attachment extends BaseClass { export class Attachment extends BaseClass {
@Column() @Column()

View File

@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { ChannelPermissionOverwrite } from "./Channel"; import { ChannelPermissionOverwrite } from "./Channel";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export enum AuditLogEvents { export enum AuditLogEvents {
// guild level // guild level
@ -113,7 +114,7 @@ export enum AuditLogEvents {
@Entity({ @Entity({
name: "audit_logs", name: "audit_logs",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class AuditLog extends BaseClass { export class AuditLog extends BaseClass {
@JoinColumn({ name: "target_id" }) @JoinColumn({ name: "target_id" })

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import crypto from "crypto"; import crypto from "crypto";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "backup_codes", name: "backup_codes",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class BackupCode extends BaseClass { export class BackupCode extends BaseClass {
@JoinColumn({ name: "user_id" }) @JoinColumn({ name: "user_id" })

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClassWithoutId } from "./BaseClass"; import { BaseClassWithoutId } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "badges", name: "badges",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Badge extends BaseClassWithoutId { export class Badge extends BaseClassWithoutId {
@Column({ primary: true }) @Column({ primary: true })

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "bans", name: "bans",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Ban extends BaseClass { export class Ban extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -18,6 +18,7 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";
// TODO: categories: // TODO: categories:
// [{ // [{
@ -35,7 +36,7 @@ import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
@Entity({ @Entity({
name: "categories", name: "categories",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Categories extends BaseClassWithoutId { export class Categories extends BaseClassWithoutId {
// Not using snowflake // Not using snowflake

View File

@ -44,6 +44,7 @@ import { Recipient } from "./Recipient";
import { PublicUserProjection, User } from "./User"; import { PublicUserProjection, User } from "./User";
import { VoiceState } from "./VoiceState"; import { VoiceState } from "./VoiceState";
import { Webhook } from "./Webhook"; import { Webhook } from "./Webhook";
import { dbEngine } from "../util/Database";
export enum ChannelType { export enum ChannelType {
GUILD_TEXT = 0, // a text channel within a guild GUILD_TEXT = 0, // a text channel within a guild
@ -71,7 +72,7 @@ export enum ChannelType {
@Entity({ @Entity({
name: "channels", name: "channels",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Channel extends BaseClass { export class Channel extends BaseClass {
@Column() @Column()

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "client_release", name: "client_release",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Release extends BaseClass { export class Release extends BaseClass {
@Column() @Column()

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "config", name: "config",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class ConfigEntity extends BaseClassWithoutId { export class ConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn() @PrimaryIdColumn()

View File

@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { ConnectedAccountTokenData } from "../interfaces"; import { ConnectedAccountTokenData } from "../interfaces";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export type PublicConnectedAccount = Pick< export type PublicConnectedAccount = Pick<
ConnectedAccount, ConnectedAccount,
@ -28,7 +29,7 @@ export type PublicConnectedAccount = Pick<
@Entity({ @Entity({
name: "connected_accounts", name: "connected_accounts",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class ConnectedAccount extends BaseClass { export class ConnectedAccount extends BaseClass {
@Column() @Column()

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "connection_config", name: "connection_config",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class ConnectionConfigEntity extends BaseClassWithoutId { export class ConnectionConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn() @PrimaryIdColumn()

View File

@ -19,10 +19,11 @@
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Entity, Column } from "typeorm"; import { Entity, Column } from "typeorm";
import { Embed } from "./Message"; import { Embed } from "./Message";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "embed_cache", name: "embed_cache",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class EmbedCache extends BaseClass { export class EmbedCache extends BaseClass {
@Column() @Column()

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { User } from "."; import { User } from ".";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "emojis", name: "emojis",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Emoji extends BaseClass { export class Emoji extends BaseClass {
@Column() @Column()

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "security_settings", name: "security_settings",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class SecuritySettings extends BaseClass { export class SecuritySettings extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -37,6 +37,7 @@ import { Template } from "./Template";
import { User } from "./User"; import { User } from "./User";
import { VoiceState } from "./VoiceState"; import { VoiceState } from "./VoiceState";
import { Webhook } from "./Webhook"; import { Webhook } from "./Webhook";
import { dbEngine } from "../util/Database";
// TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0} // TODO: application_command_count, application_command_counts: {1: 0, 2: 0, 3: 0}
// TODO: guild_scheduled_events // TODO: guild_scheduled_events
@ -68,7 +69,7 @@ export const PublicGuildRelations = [
@Entity({ @Entity({
name: "guilds", name: "guilds",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Guild extends BaseClass { export class Guild extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -22,12 +22,13 @@ import { Channel } from "./Channel";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { Member } from "./Member"; import { Member } from "./Member";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export const PublicInviteRelation = ["inviter", "guild", "channel"]; export const PublicInviteRelation = ["inviter", "guild", "channel"];
@Entity({ @Entity({
name: "invites", name: "invites",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Invite extends BaseClassWithoutId { export class Invite extends BaseClassWithoutId {
@PrimaryIdColumn() @PrimaryIdColumn()

View File

@ -48,6 +48,7 @@ import { Guild } from "./Guild";
import { Message } from "./Message"; import { Message } from "./Message";
import { Role } from "./Role"; import { Role } from "./Role";
import { PublicUser, User } from "./User"; import { PublicUser, User } from "./User";
import { dbEngine } from "../util/Database";
export const MemberPrivateProjection: (keyof Member)[] = [ export const MemberPrivateProjection: (keyof Member)[] = [
"id", "id",
@ -67,7 +68,7 @@ export const MemberPrivateProjection: (keyof Member)[] = [
@Entity({ @Entity({
name: "members", name: "members",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
@Index(["id", "guild_id"], { unique: true }) @Index(["id", "guild_id"], { unique: true })
export class Member extends BaseClassWithoutId { export class Member extends BaseClassWithoutId {

View File

@ -39,6 +39,7 @@ import { Guild } from "./Guild";
import { Webhook } from "./Webhook"; import { Webhook } from "./Webhook";
import { Sticker } from "./Sticker"; import { Sticker } from "./Sticker";
import { Attachment } from "./Attachment"; import { Attachment } from "./Attachment";
import { dbEngine } from "../util/Database";
export enum MessageType { export enum MessageType {
DEFAULT = 0, DEFAULT = 0,
@ -70,7 +71,7 @@ export enum MessageType {
@Entity({ @Entity({
name: "messages", name: "messages",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
@Index(["channel_id", "id"], { unique: true }) @Index(["channel_id", "id"], { unique: true })
export class Message extends BaseClass { export class Message extends BaseClass {

View File

@ -23,6 +23,7 @@ import {
PrimaryGeneratedColumn, PrimaryGeneratedColumn,
BaseEntity, BaseEntity,
} from "typeorm"; } from "typeorm";
import { dbEngine } from "../util/Database";
export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith( export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
"mongodb", "mongodb",
@ -32,7 +33,7 @@ export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
@Entity({ @Entity({
name: "migrations", name: "migrations",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Migration extends BaseEntity { export class Migration extends BaseEntity {
@PrimaryIdAutoGenerated() @PrimaryIdAutoGenerated()

View File

@ -19,10 +19,11 @@
import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "notes", name: "notes",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
@Unique(["owner", "target"]) @Unique(["owner", "target"])
export class Note extends BaseClass { export class Note extends BaseClass {

View File

@ -18,10 +18,11 @@
import { Column, Entity } from "typeorm"; import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "rate_limits", name: "rate_limits",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class RateLimit extends BaseClass { export class RateLimit extends BaseClass {
@Column() // no relation as it also @Column() // no relation as it also

View File

@ -27,6 +27,7 @@ import {
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Channel } from "./Channel"; import { Channel } from "./Channel";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
// for read receipts // 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 // 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({ @Entity({
name: "read_states", name: "read_states",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
@Index(["channel_id", "user_id"], { unique: true }) @Index(["channel_id", "user_id"], { unique: true })
export class ReadState extends BaseClass { export class ReadState extends BaseClass {

View File

@ -18,10 +18,11 @@
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "recipients", name: "recipients",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Recipient extends BaseClass { export class Recipient extends BaseClass {
@Column() @Column()

View File

@ -26,6 +26,7 @@ import {
} from "typeorm"; } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export enum RelationshipType { export enum RelationshipType {
outgoing = 4, outgoing = 4,
@ -36,7 +37,7 @@ export enum RelationshipType {
@Entity({ @Entity({
name: "relationships", name: "relationships",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
@Index(["from_id", "to_id"], { unique: true }) @Index(["from_id", "to_id"], { unique: true })
export class Relationship extends BaseClass { export class Relationship extends BaseClass {

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "roles", name: "roles",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Role extends BaseClass { export class Role extends BaseClass {
@Column() @Column()

View File

@ -19,10 +19,11 @@
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "security_keys", name: "security_keys",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class SecurityKey extends BaseClass { export class SecurityKey extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -21,12 +21,13 @@ import { BaseClass } from "./BaseClass";
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { ClientStatus, Status } from "../interfaces/Status"; import { ClientStatus, Status } from "../interfaces/Status";
import { Activity } from "../interfaces/Activity"; 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 //TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
@Entity({ @Entity({
name: "sessions", name: "sessions",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Session extends BaseClass { export class Session extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -20,6 +20,7 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export enum StickerType { export enum StickerType {
STANDARD = 1, STANDARD = 1,
@ -35,7 +36,7 @@ export enum StickerFormatType {
@Entity({ @Entity({
name: "stickers", name: "stickers",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Sticker extends BaseClass { export class Sticker extends BaseClass {
@Column() @Column()

View File

@ -26,10 +26,11 @@ import {
} from "typeorm"; } from "typeorm";
import { Sticker } from "."; import { Sticker } from ".";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "sticker_packs", name: "sticker_packs",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class StickerPack extends BaseClass { export class StickerPack extends BaseClass {
@Column() @Column()

View File

@ -27,10 +27,11 @@ import {
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { TeamMember } from "./TeamMember"; import { TeamMember } from "./TeamMember";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "teams", name: "teams",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Team extends BaseClass { export class Team extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -19,6 +19,7 @@
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export enum TeamMemberState { export enum TeamMemberState {
INVITED = 1, INVITED = 1,
@ -27,7 +28,7 @@ export enum TeamMemberState {
@Entity({ @Entity({
name: "team_members", name: "team_members",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class TeamMember extends BaseClass { export class TeamMember extends BaseClass {
@Column({ type: "int" }) @Column({ type: "int" })

View File

@ -20,10 +20,11 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "templates", name: "templates",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Template extends BaseClass { export class Template extends BaseClass {
@Column({ unique: true }) @Column({ unique: true })

View File

@ -34,6 +34,7 @@ import { Relationship } from "./Relationship";
import { SecurityKey } from "./SecurityKey"; import { SecurityKey } from "./SecurityKey";
import { Session } from "./Session"; import { Session } from "./Session";
import { UserSettings } from "./UserSettings"; import { UserSettings } from "./UserSettings";
import { dbEngine } from "../util/Database";
export enum PublicUserEnum { export enum PublicUserEnum {
username, username,
@ -88,7 +89,7 @@ export interface UserPrivate extends Pick<User, PrivateUserKeys> {
@Entity({ @Entity({
name: "users", name: "users",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class User extends BaseClass { export class User extends BaseClass {
@Column() @Column()

View File

@ -18,10 +18,11 @@
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { BaseClassWithoutId } from "./BaseClass"; import { BaseClassWithoutId } from "./BaseClass";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "user_settings", name: "user_settings",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class UserSettings extends BaseClassWithoutId { export class UserSettings extends BaseClassWithoutId {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()

View File

@ -17,10 +17,11 @@
*/ */
import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm"; import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm";
import { dbEngine } from "../util/Database";
@Entity({ @Entity({
name: "valid_registration_tokens", name: "valid_registration_tokens",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class ValidRegistrationToken extends BaseEntity { export class ValidRegistrationToken extends BaseEntity {
@PrimaryColumn() @PrimaryColumn()

View File

@ -22,11 +22,12 @@ import { Channel } from "./Channel";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { Member } from "./Member"; import { Member } from "./Member";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
//https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex //https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex
@Entity({ @Entity({
name: "voice_states", name: "voice_states",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class VoiceState extends BaseClass { export class VoiceState extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })

View File

@ -22,6 +22,7 @@ import { BaseClass } from "./BaseClass";
import { Channel } from "./Channel"; import { Channel } from "./Channel";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { User } from "./User"; import { User } from "./User";
import { dbEngine } from "../util/Database";
export enum WebhookType { export enum WebhookType {
Incoming = 1, Incoming = 1,
@ -31,7 +32,7 @@ export enum WebhookType {
@Entity({ @Entity({
name: "webhooks", name: "webhooks",
engine: "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", engine: dbEngine,
}) })
export class Webhook extends BaseClass { export class Webhook extends BaseClass {
@Column({ type: "int" }) @Column({ type: "int" })

View File

@ -1,17 +1,17 @@
/* /*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify 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 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 by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details. GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
@ -134,3 +134,6 @@ export { DataSourceOptions, DatabaseType, dbConnection };
export async function closeDatabase() { export async function closeDatabase() {
await dbConnection?.destroy(); await dbConnection?.destroy();
} }
export const dbEngine =
"InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";