Skip to content

Commit

Permalink
"engine" const value shared
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Aug 18, 2024
1 parent 99c75d3 commit dfbbef3
Show file tree
Hide file tree
Showing 39 changed files with 82 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/util/entities/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/AuditLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/BackupCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Ban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
import { dbEngine } from "../util/Database";

// TODO: categories:
// [{
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/ClientRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/ConnectedAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/ConnectionConfigEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/EmbedCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 })
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
PrimaryGeneratedColumn,
BaseEntity,
} from "typeorm";
import { dbEngine } from "../util/Database";

export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
"mongodb",
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/RateLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/ReadState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ 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
// public read receipt ≥ notification cursor ≥ private fully read marker

@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 {
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/util/entities/SecurityKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
Loading

0 comments on commit dfbbef3

Please sign in to comment.