diff --git a/package-lock.json b/package-lock.json
index 300d754d..1c6a213f 100644
Binary files a/package-lock.json and b/package-lock.json differ
diff --git a/package.json b/package.json
index 2cb573f6..246c5617 100644
--- a/package.json
+++ b/package.json
@@ -69,8 +69,8 @@
"husky": "^9.1.7",
"prettier": "^3.6.2",
"pretty-quick": "^4.2.2",
- "typescript": "^5.9.2",
- "ts-node": "^10.9.2"
+ "ts-node": "^10.9.2",
+ "typescript": "^5.9.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.899.0",
@@ -126,7 +126,6 @@
"@yukikaze-bot/erlpack": "^1.0.1",
"jimp": "^1.6.0",
"mailgun.js": "^12.1.0",
- "mysql": "^2.18.1",
"node-mailjet": "^6.0.9",
"nodemailer": "^7.0.6",
"pg": "^8.16.3",
diff --git a/src/util/entities/Application.ts b/src/util/entities/Application.ts
index 747ef860..d81226d8 100644
--- a/src/util/entities/Application.ts
+++ b/src/util/entities/Application.ts
@@ -27,12 +27,10 @@ import {
import { BaseClass } from "./BaseClass";
import { Team } from "./Team";
import { User } from "./User";
-import { dbEngine } from "../util/Database";
import { Guild } from "./Guild";
@Entity({
name: "applications",
- engine: dbEngine,
})
export class Application extends BaseClass {
@Column()
diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts
index b2741ed0..ba3e7afb 100644
--- a/src/util/entities/Attachment.ts
+++ b/src/util/entities/Attachment.ts
@@ -27,7 +27,6 @@ import {
import { URL } from "url";
import { deleteFile } from "../util/cdn";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
import {
getUrlSignature,
NewUrlUserSignatureData,
@@ -36,7 +35,6 @@ import {
@Entity({
name: "attachments",
- engine: dbEngine,
})
export class Attachment extends BaseClass {
@Column()
diff --git a/src/util/entities/AuditLog.ts b/src/util/entities/AuditLog.ts
index 49c836c3..cc23bf5e 100644
--- a/src/util/entities/AuditLog.ts
+++ b/src/util/entities/AuditLog.ts
@@ -20,7 +20,6 @@ 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
@@ -114,7 +113,6 @@ export enum AuditLogEvents {
@Entity({
name: "audit_logs",
- engine: dbEngine,
})
export class AuditLog extends BaseClass {
@JoinColumn({ name: "target_id" })
diff --git a/src/util/entities/AutomodRule.ts b/src/util/entities/AutomodRule.ts
index a45a7c15..e30dd0c0 100644
--- a/src/util/entities/AutomodRule.ts
+++ b/src/util/entities/AutomodRule.ts
@@ -16,7 +16,6 @@
along with this program. If not, see .
*/
-import { dbEngine } from "@spacebar/util";
import { BaseClass } from "./BaseClass";
import { Entity, JoinColumn, ManyToOne, Column } from "typeorm";
import { User } from "./User";
@@ -41,7 +40,6 @@ export class AutomodCustomWordsRule {
@Entity({
name: "automod_rules",
- engine: dbEngine,
})
export class AutomodRule extends BaseClass {
@JoinColumn({ name: "creator_id" })
diff --git a/src/util/entities/BackupCodes.ts b/src/util/entities/BackupCodes.ts
index 9afc181a..31c76343 100644
--- a/src/util/entities/BackupCodes.ts
+++ b/src/util/entities/BackupCodes.ts
@@ -20,11 +20,9 @@ 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: 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 4b98006a..38489e8b 100644
--- a/src/util/entities/Badge.ts
+++ b/src/util/entities/Badge.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClassWithoutId } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "badges",
- 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 ed5f47e1..d4a7bc1c 100644
--- a/src/util/entities/Ban.ts
+++ b/src/util/entities/Ban.ts
@@ -20,11 +20,9 @@ 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: dbEngine,
})
export class Ban extends BaseClass {
@Column({ nullable: true })
diff --git a/src/util/entities/Categories.ts b/src/util/entities/Categories.ts
index 990e7fdd..6221f62a 100644
--- a/src/util/entities/Categories.ts
+++ b/src/util/entities/Categories.ts
@@ -18,7 +18,6 @@
import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
-import { dbEngine } from "../util/Database";
// TODO: categories:
// [{
@@ -36,7 +35,6 @@ import { dbEngine } from "../util/Database";
@Entity({
name: "categories",
- 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 c7d84055..f466474e 100644
--- a/src/util/entities/Channel.ts
+++ b/src/util/entities/Channel.ts
@@ -37,7 +37,6 @@ import { Recipient } from "./Recipient";
import { PublicUserProjection, User } from "./User";
import { VoiceState } from "./VoiceState";
import { Webhook } from "./Webhook";
-import { dbEngine } from "../util/Database";
import { Member } from "./Member";
export enum ChannelType {
@@ -66,7 +65,6 @@ export enum ChannelType {
@Entity({
name: "channels",
- engine: dbEngine,
})
export class Channel extends BaseClass {
@Column()
diff --git a/src/util/entities/ClientRelease.ts b/src/util/entities/ClientRelease.ts
index 9eb6750a..0da1f0be 100644
--- a/src/util/entities/ClientRelease.ts
+++ b/src/util/entities/ClientRelease.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "client_release",
- engine: dbEngine,
})
export class ClientRelease extends BaseClass {
@Column()
diff --git a/src/util/entities/CloudAttachment.ts b/src/util/entities/CloudAttachment.ts
index 415dcf81..de1e34ea 100644
--- a/src/util/entities/CloudAttachment.ts
+++ b/src/util/entities/CloudAttachment.ts
@@ -18,13 +18,11 @@
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
import { User } from "./User";
import { Channel } from "./Channel";
@Entity({
name: "cloud_attachments",
- engine: dbEngine,
})
export class CloudAttachment extends BaseClass {
// Internal tracking metadata
diff --git a/src/util/entities/Config.ts b/src/util/entities/Config.ts
index 8d725a12..964cb223 100644
--- a/src/util/entities/Config.ts
+++ b/src/util/entities/Config.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "config",
- engine: dbEngine,
})
export class ConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn()
diff --git a/src/util/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts
index 0c9eb402..51df3955 100644
--- a/src/util/entities/ConnectedAccount.ts
+++ b/src/util/entities/ConnectedAccount.ts
@@ -20,7 +20,6 @@ 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,
@@ -29,7 +28,6 @@ export type PublicConnectedAccount = Pick<
@Entity({
name: "connected_accounts",
- engine: dbEngine,
})
export class ConnectedAccount extends BaseClass {
@Column()
diff --git a/src/util/entities/ConnectionConfigEntity.ts b/src/util/entities/ConnectionConfigEntity.ts
index 9d4dde60..75c4a801 100644
--- a/src/util/entities/ConnectionConfigEntity.ts
+++ b/src/util/entities/ConnectionConfigEntity.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "connection_config",
- engine: dbEngine,
})
export class ConnectionConfigEntity extends BaseClassWithoutId {
@PrimaryIdColumn()
diff --git a/src/util/entities/EmbedCache.ts b/src/util/entities/EmbedCache.ts
index 8d68b0ac..f9358b5b 100644
--- a/src/util/entities/EmbedCache.ts
+++ b/src/util/entities/EmbedCache.ts
@@ -19,11 +19,9 @@
import { BaseClass } from "./BaseClass";
import { Entity, Column } from "typeorm";
import { Embed } from "./Message";
-import { dbEngine } from "../util/Database";
@Entity({
name: "embed_cache",
- engine: dbEngine,
})
export class EmbedCache extends BaseClass {
@Column()
diff --git a/src/util/entities/Emoji.ts b/src/util/entities/Emoji.ts
index 198d5faf..1a71e592 100644
--- a/src/util/entities/Emoji.ts
+++ b/src/util/entities/Emoji.ts
@@ -20,11 +20,9 @@ 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: dbEngine,
})
export class Emoji extends BaseClass {
@Column()
diff --git a/src/util/entities/Encryption.ts b/src/util/entities/Encryption.ts
index 21e77b48..12be1d08 100644
--- a/src/util/entities/Encryption.ts
+++ b/src/util/entities/Encryption.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "security_settings",
- 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 37728aa6..0b09f859 100644
--- a/src/util/entities/Guild.ts
+++ b/src/util/entities/Guild.ts
@@ -30,7 +30,6 @@ 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
@@ -62,7 +61,6 @@ export const PublicGuildRelations = [
@Entity({
name: "guilds",
- engine: dbEngine,
})
export class Guild extends BaseClass {
@Column({ type: String, nullable: true })
diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts
index 29e2ac1f..13041377 100644
--- a/src/util/entities/Invite.ts
+++ b/src/util/entities/Invite.ts
@@ -22,13 +22,11 @@ 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: dbEngine,
})
export class Invite extends BaseClassWithoutId {
@PrimaryIdColumn()
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 0ed728fc..44ccacfb 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -48,7 +48,6 @@ 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",
@@ -68,7 +67,6 @@ export const MemberPrivateProjection: (keyof Member)[] = [
@Entity({
name: "members",
- 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 b609325a..fcb9fbe8 100644
--- a/src/util/entities/Message.ts
+++ b/src/util/entities/Message.ts
@@ -39,7 +39,6 @@ import { Guild } from "./Guild";
import { Webhook } from "./Webhook";
import { Sticker } from "./Sticker";
import { Attachment } from "./Attachment";
-import { dbEngine } from "../util/Database";
import { NewUrlUserSignatureData } from "../Signing";
export enum MessageType {
@@ -72,7 +71,6 @@ export enum MessageType {
@Entity({
name: "messages",
- 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 f0ee3e07..71c50e52 100644
--- a/src/util/entities/Migration.ts
+++ b/src/util/entities/Migration.ts
@@ -23,7 +23,6 @@ import {
PrimaryGeneratedColumn,
BaseEntity,
} from "typeorm";
-import { dbEngine } from "../util/Database";
export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
"mongodb",
@@ -33,7 +32,6 @@ export const PrimaryIdAutoGenerated = process.env.DATABASE?.startsWith(
@Entity({
name: "migrations",
- engine: dbEngine,
})
export class Migration extends BaseEntity {
@PrimaryIdAutoGenerated()
diff --git a/src/util/entities/Note.ts b/src/util/entities/Note.ts
index 9773c802..c1b12527 100644
--- a/src/util/entities/Note.ts
+++ b/src/util/entities/Note.ts
@@ -19,11 +19,9 @@
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: dbEngine,
})
@Unique(["owner", "target"])
export class Note extends BaseClass {
diff --git a/src/util/entities/RateLimit.ts b/src/util/entities/RateLimit.ts
index ba2b7931..04c8abbb 100644
--- a/src/util/entities/RateLimit.ts
+++ b/src/util/entities/RateLimit.ts
@@ -18,11 +18,9 @@
import { Column, Entity } from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "rate_limits",
- 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 9f362547..36916e11 100644
--- a/src/util/entities/ReadState.ts
+++ b/src/util/entities/ReadState.ts
@@ -27,7 +27,6 @@ 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
@@ -35,7 +34,6 @@ import { dbEngine } from "../util/Database";
@Entity({
name: "read_states",
- 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 26896220..37a2cb41 100644
--- a/src/util/entities/Recipient.ts
+++ b/src/util/entities/Recipient.ts
@@ -18,11 +18,9 @@
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "recipients",
- engine: dbEngine,
})
export class Recipient extends BaseClass {
@Column()
diff --git a/src/util/entities/Relationship.ts b/src/util/entities/Relationship.ts
index d8dfc289..0fe89c35 100644
--- a/src/util/entities/Relationship.ts
+++ b/src/util/entities/Relationship.ts
@@ -26,7 +26,6 @@ import {
} from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
-import { dbEngine } from "../util/Database";
export enum RelationshipType {
outgoing = 4,
@@ -37,7 +36,6 @@ export enum RelationshipType {
@Entity({
name: "relationships",
- 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 a58742ad..f31c4b32 100644
--- a/src/util/entities/Role.ts
+++ b/src/util/entities/Role.ts
@@ -20,7 +20,6 @@ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { Guild } from "./Guild";
-import { dbEngine } from "../util/Database";
export class RoleColors {
primary_color: number;
@@ -38,7 +37,6 @@ export class RoleColors {
@Entity({
name: "roles",
- engine: dbEngine,
})
export class Role extends BaseClass {
@Column()
diff --git a/src/util/entities/SecurityKey.ts b/src/util/entities/SecurityKey.ts
index efe46c81..94adbbc4 100644
--- a/src/util/entities/SecurityKey.ts
+++ b/src/util/entities/SecurityKey.ts
@@ -19,11 +19,9 @@
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: dbEngine,
})
export class SecurityKey extends BaseClass {
@Column({ nullable: true })
diff --git a/src/util/entities/Session.ts b/src/util/entities/Session.ts
index 5c3d5a4f..3d95f413 100644
--- a/src/util/entities/Session.ts
+++ b/src/util/entities/Session.ts
@@ -21,13 +21,11 @@ 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: dbEngine,
})
export class Session extends BaseClass {
@Column({ nullable: true })
diff --git a/src/util/entities/Sticker.ts b/src/util/entities/Sticker.ts
index 78b6d207..4c950cbb 100644
--- a/src/util/entities/Sticker.ts
+++ b/src/util/entities/Sticker.ts
@@ -20,7 +20,6 @@ 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,
@@ -36,7 +35,6 @@ export enum StickerFormatType {
@Entity({
name: "stickers",
- engine: dbEngine,
})
export class Sticker extends BaseClass {
@Column()
diff --git a/src/util/entities/StickerPack.ts b/src/util/entities/StickerPack.ts
index 43d27d60..20d7d7dc 100644
--- a/src/util/entities/StickerPack.ts
+++ b/src/util/entities/StickerPack.ts
@@ -26,11 +26,9 @@ import {
} from "typeorm";
import { Sticker } from ".";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "sticker_packs",
- engine: dbEngine,
})
export class StickerPack extends BaseClass {
@Column()
diff --git a/src/util/entities/Stream.ts b/src/util/entities/Stream.ts
index 01d621fa..e751cc4a 100644
--- a/src/util/entities/Stream.ts
+++ b/src/util/entities/Stream.ts
@@ -6,13 +6,11 @@ import {
RelationId,
} from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
import { User } from "./User";
import { Channel } from "./Channel";
@Entity({
name: "streams",
- engine: dbEngine,
})
export class Stream extends BaseClass {
@Column()
diff --git a/src/util/entities/StreamSession.ts b/src/util/entities/StreamSession.ts
index 472b22b6..ca210bf1 100644
--- a/src/util/entities/StreamSession.ts
+++ b/src/util/entities/StreamSession.ts
@@ -6,13 +6,11 @@ import {
RelationId,
} from "typeorm";
import { BaseClass } from "./BaseClass";
-import { dbEngine } from "../util/Database";
import { User } from "./User";
import { Stream } from "./Stream";
@Entity({
name: "stream_sessions",
- engine: dbEngine,
})
export class StreamSession extends BaseClass {
@Column()
diff --git a/src/util/entities/Team.ts b/src/util/entities/Team.ts
index 6b3fa554..3f8c5ff5 100644
--- a/src/util/entities/Team.ts
+++ b/src/util/entities/Team.ts
@@ -27,11 +27,9 @@ import {
import { BaseClass } from "./BaseClass";
import { TeamMember } from "./TeamMember";
import { User } from "./User";
-import { dbEngine } from "../util/Database";
@Entity({
name: "teams",
- 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 e4c18b89..d3d066bd 100644
--- a/src/util/entities/TeamMember.ts
+++ b/src/util/entities/TeamMember.ts
@@ -19,7 +19,6 @@
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,
@@ -33,7 +32,6 @@ export enum TeamMemberRole {
@Entity({
name: "team_members",
- 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 faf6454a..bd48582e 100644
--- a/src/util/entities/Template.ts
+++ b/src/util/entities/Template.ts
@@ -20,11 +20,9 @@ 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: dbEngine,
})
export class Template extends BaseClass {
@Column({ unique: true })
diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index 03b6b365..2375008e 100644
--- a/src/util/entities/User.ts
+++ b/src/util/entities/User.ts
@@ -27,7 +27,6 @@ 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,
@@ -77,7 +76,6 @@ export interface UserPrivate extends Pick {
@Entity({
name: "users",
- engine: dbEngine,
})
export class User extends BaseClass {
@Column()
diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts
index cbb1cbcf..1a196871 100644
--- a/src/util/entities/UserSettings.ts
+++ b/src/util/entities/UserSettings.ts
@@ -18,11 +18,9 @@
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { BaseClassWithoutId } from "./BaseClass";
-import { dbEngine } from "../util/Database";
@Entity({
name: "user_settings",
- engine: dbEngine,
})
export class UserSettings extends BaseClassWithoutId {
@PrimaryGeneratedColumn()
diff --git a/src/util/entities/UserSettingsProtos.ts b/src/util/entities/UserSettingsProtos.ts
index d7a23199..eb2a1871 100644
--- a/src/util/entities/UserSettingsProtos.ts
+++ b/src/util/entities/UserSettingsProtos.ts
@@ -18,7 +18,6 @@
import { Column, Entity, JoinColumn, OneToOne } from "typeorm";
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
-import { dbEngine } from "@spacebar/util";
import { User } from "./User";
import {
FrecencyUserSettings,
@@ -32,7 +31,6 @@ import {
@Entity({
name: "user_settings_protos",
- engine: dbEngine,
})
export class UserSettingsProtos extends BaseClassWithoutId {
@OneToOne(() => User, {
diff --git a/src/util/entities/ValidRegistrationTokens.ts b/src/util/entities/ValidRegistrationTokens.ts
index 70945765..20e2c76c 100644
--- a/src/util/entities/ValidRegistrationTokens.ts
+++ b/src/util/entities/ValidRegistrationTokens.ts
@@ -17,11 +17,9 @@
*/
import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm";
-import { dbEngine } from "../util/Database";
@Entity({
name: "valid_registration_tokens",
- engine: dbEngine,
})
export class ValidRegistrationToken extends BaseEntity {
@PrimaryColumn()
diff --git a/src/util/entities/VoiceState.ts b/src/util/entities/VoiceState.ts
index 549d667f..475f0f6f 100644
--- a/src/util/entities/VoiceState.ts
+++ b/src/util/entities/VoiceState.ts
@@ -22,7 +22,6 @@ import { Channel } from "./Channel";
import { Guild } from "./Guild";
import { Member } from "./Member";
import { User } from "./User";
-import { dbEngine } from "../util/Database";
export enum PublicVoiceStateEnum {
user_id,
@@ -50,7 +49,6 @@ export type PublicVoiceState = Pick;
//https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex
@Entity({
name: "voice_states",
- 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 473352c8..f28be1ce 100644
--- a/src/util/entities/Webhook.ts
+++ b/src/util/entities/Webhook.ts
@@ -22,7 +22,6 @@ 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,
@@ -32,7 +31,6 @@ export enum WebhookType {
@Entity({
name: "webhooks",
- engine: dbEngine,
})
export class Webhook extends BaseClass {
@Column({ type: "int" })
diff --git a/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts b/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts
deleted file mode 100644
index 483c5070..00000000
--- a/src/util/migration/mariadb/1673609465036-templateDeleteCascade.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- 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 { MigrationInterface, QueryRunner } from "typeorm";
-
-export class templateDeleteCascade1673609465036 implements MigrationInterface {
- name = "templateDeleteCascade1673609465036";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
- );
- }
-}
diff --git a/src/util/migration/mariadb/1675045120206-webauthn.ts b/src/util/migration/mariadb/1675045120206-webauthn.ts
deleted file mode 100644
index d58ac88d..00000000
--- a/src/util/migration/mariadb/1675045120206-webauthn.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- 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 { MigrationInterface, QueryRunner } from "typeorm";
-
-export class webauthn1675045120206 implements MigrationInterface {
- name = "webauthn1675045120206";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `CREATE TABLE \`security_keys\` (\`id\` varchar(255) NOT NULL, \`user_id\` varchar(255) NULL, \`key_id\` varchar(255) NOT NULL, \`public_key\` varchar(255) NOT NULL, \`counter\` int NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` ADD \`webauthn_enabled\` tinyint NOT NULL DEFAULT 0`,
- );
- await queryRunner.query(
- `ALTER TABLE \`security_keys\` ADD CONSTRAINT \`FK_24c97d0771cafedce6d7163eaad\` FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`security_keys\` DROP FOREIGN KEY \`FK_24c97d0771cafedce6d7163eaad\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` DROP COLUMN \`webauthn_enabled\``,
- );
- await queryRunner.query(`DROP TABLE \`security_keys\``);
- }
-}
diff --git a/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts b/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts
deleted file mode 100644
index 083f3680..00000000
--- a/src/util/migration/mariadb/1696420827239-guildChannelOrdering.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class guildChannelOrdering1696420827239 implements MigrationInterface {
- name = "guildChannelOrdering1696420827239";
-
- public async up(queryRunner: QueryRunner): Promise {
- const guilds = await queryRunner.query(
- `SELECT id FROM guilds`,
- undefined,
- true,
- );
-
- await queryRunner.query(
- `ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`,
- );
-
- for (const guild_id of guilds.records.map((x) => x.id)) {
- const channels: Array<{ position: number; id: string }> = (
- await queryRunner.query(
- `SELECT id, position FROM channels WHERE guild_id = ?`,
- [guild_id],
- true,
- )
- ).records;
-
- channels.sort((a, b) => a.position - b.position);
-
- await queryRunner.query(
- `UPDATE guilds SET channel_ordering = ? WHERE id = ?`,
- [JSON.stringify(channels.map((x) => x.id)), guild_id],
- );
- }
-
- await queryRunner.query(`ALTER TABLE channels DROP COLUMN position`);
- }
-
- public async down(): Promise {
- // don't care actually, sorry.
- }
-}
diff --git a/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts b/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts
deleted file mode 100644
index 7be2ad70..00000000
--- a/src/util/migration/mariadb/1713116476900-messageFlagsNotNull.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class MessageFlagsNotNull1713116476900 implements MigrationInterface {
- name = "MessageFlagsNotNull1713116476900";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` CHANGE flags flags_old integer;",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` ADD flags integer NOT NULL DEFAULT 0;",
- );
- await queryRunner.query(
- "UPDATE `messages` SET flags = IFNULL(flags_old, 0);",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` DROP COLUMN flags_old;",
- );
- }
-
- public async down(): Promise {
- // dont care
- throw new Error("Migration down is not implemented.");
- }
-}
diff --git a/src/util/migration/mariadb/1719776735000-newUserSettings.ts b/src/util/migration/mariadb/1719776735000-newUserSettings.ts
deleted file mode 100644
index f7c37ca9..00000000
--- a/src/util/migration/mariadb/1719776735000-newUserSettings.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class NewUserSettings1719776735000 implements MigrationInterface {
- name = "NewUserSettings1719776735000";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `user_settings` ADD friend_discovery_flags integer NULL DEFAULT 0;",
- );
- await queryRunner.query(
- "ALTER TABLE `user_settings` ADD view_nsfw_guilds tinyint NULL DEFAULT 1;",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `user_settings` DROP COLUMN friend_discovery_flags;",
- );
- await queryRunner.query(
- "ALTER TABLE `user_settings` DROP COLUMN view_nsfw_guilds;",
- );
- }
-}
diff --git a/src/util/migration/mariadb/1720157926878-messagePollObject.ts b/src/util/migration/mariadb/1720157926878-messagePollObject.ts
deleted file mode 100644
index c0866426..00000000
--- a/src/util/migration/mariadb/1720157926878-messagePollObject.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class MessagePollObject1720157926878 implements MigrationInterface {
- name = "MessagePollObject1720157926878";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
- }
-}
diff --git a/src/util/migration/mariadb/1720628601997-badges.ts b/src/util/migration/mariadb/1720628601997-badges.ts
deleted file mode 100644
index af298e42..00000000
--- a/src/util/migration/mariadb/1720628601997-badges.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class Badges1720628601997 implements MigrationInterface {
- name = "Badges1720628601997";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `CREATE TABLE \`badges\` (\`id\` varchar(255) NOT NULL, \`description\` varchar(255) NOT NULL, \`icon\` varchar(255) NOT NULL, \`link\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` ADD \`badge_ids\` text NULL`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`users\` DROP COLUMN \`badge_ids\``,
- );
- await queryRunner.query(`DROP TABLE \`badges\``);
- }
-}
diff --git a/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts b/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts
deleted file mode 100644
index 775847e0..00000000
--- a/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class WebhookMessageProperties1721298824927
- implements MigrationInterface
-{
- name = "WebhookMessageProperties1721298824927";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` ADD `username` text NULL",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` ADD `avatar` text NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` DROP COLUMN `username`",
- );
- await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`");
- }
-}
diff --git a/src/util/migration/mariadb/1723347738541-client_status.ts b/src/util/migration/mariadb/1723347738541-client_status.ts
deleted file mode 100644
index 0e02c45e..00000000
--- a/src/util/migration/mariadb/1723347738541-client_status.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class client_status1723347738541 implements MigrationInterface {
- name = "client_status1723347738541";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `sessions` ADD `client_status` text NULL AFTER `client_info`",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `sessions` DROP COLUMN `client_status`",
- );
- }
-}
diff --git a/src/util/migration/mariadb/1723577874393-discoveryCategoryIcon.ts b/src/util/migration/mariadb/1723577874393-discoveryCategoryIcon.ts
deleted file mode 100644
index 18bc0a77..00000000
--- a/src/util/migration/mariadb/1723577874393-discoveryCategoryIcon.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class DiscoveryCategoryIcon1723577874393 implements MigrationInterface {
- name = "DiscoveryCategoryIcon1723577874393";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `categories` ADD `icon` text NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `categories` DROP COLUMN `icon`");
- }
-}
diff --git a/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts b/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts
deleted file mode 100644
index ac2b1799..00000000
--- a/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class WebhookSourceChannel1723644478176 implements MigrationInterface {
- name = "WebhookSourceChannel1723644478176";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`",
- );
- await queryRunner.query(
- "ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`",
- );
- await queryRunner.query(
- "ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`",
- );
- }
-}
diff --git a/src/util/migration/mariadb/1724477620293-teamMemberRole.ts b/src/util/migration/mariadb/1724477620293-teamMemberRole.ts
deleted file mode 100644
index ff4be7bf..00000000
--- a/src/util/migration/mariadb/1724477620293-teamMemberRole.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class TeamMemberRole1724477620293 implements MigrationInterface {
- name = "TeamMemberRole1724477620293";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `team_members` ADD COLUMN `role` VARCHAR(255) NOT NULL AFTER `permissions`",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `team_members` DROP COLUMN `role`",
- );
- }
-}
diff --git a/src/util/migration/mariadb/1725090962922-applicationProperties.ts b/src/util/migration/mariadb/1725090962922-applicationProperties.ts
deleted file mode 100644
index 6ba9077c..00000000
--- a/src/util/migration/mariadb/1725090962922-applicationProperties.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class ApplicationProperties1725090962922 implements MigrationInterface {
- name = "ApplicationProperties1725090962922";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `applications` ADD COLUMN `guild_id` VARCHAR(255) DEFAULT NULL",
- );
- await queryRunner.query(
- "ALTER TABLE `applications` ADD COLUMN `custom_install_url` TEXT DEFAULT NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `applications` DROP COLUMN `guild_id`",
- );
- await queryRunner.query(
- "ALTER TABLE `applications` DROP COLUMN `custom_install_url`",
- );
- }
-}
diff --git a/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts b/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts
deleted file mode 100644
index 483c5070..00000000
--- a/src/util/migration/mysql/1673609465036-templateDeleteCascade.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- 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 { MigrationInterface, QueryRunner } from "typeorm";
-
-export class templateDeleteCascade1673609465036 implements MigrationInterface {
- name = "templateDeleteCascade1673609465036";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`templates\` DROP FOREIGN KEY \`FK_445d00eaaea0e60a017a5ed0c11\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`templates\` ADD CONSTRAINT \`FK_445d00eaaea0e60a017a5ed0c11\` FOREIGN KEY (\`source_guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
- );
- }
-}
diff --git a/src/util/migration/mysql/1675045120206-webauthn.ts b/src/util/migration/mysql/1675045120206-webauthn.ts
deleted file mode 100644
index d58ac88d..00000000
--- a/src/util/migration/mysql/1675045120206-webauthn.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- 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 { MigrationInterface, QueryRunner } from "typeorm";
-
-export class webauthn1675045120206 implements MigrationInterface {
- name = "webauthn1675045120206";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `CREATE TABLE \`security_keys\` (\`id\` varchar(255) NOT NULL, \`user_id\` varchar(255) NULL, \`key_id\` varchar(255) NOT NULL, \`public_key\` varchar(255) NOT NULL, \`counter\` int NOT NULL, \`name\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` ADD \`webauthn_enabled\` tinyint NOT NULL DEFAULT 0`,
- );
- await queryRunner.query(
- `ALTER TABLE \`security_keys\` ADD CONSTRAINT \`FK_24c97d0771cafedce6d7163eaad\` FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`security_keys\` DROP FOREIGN KEY \`FK_24c97d0771cafedce6d7163eaad\``,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` DROP COLUMN \`webauthn_enabled\``,
- );
- await queryRunner.query(`DROP TABLE \`security_keys\``);
- }
-}
diff --git a/src/util/migration/mysql/1696420827239-guildChannelOrdering.ts b/src/util/migration/mysql/1696420827239-guildChannelOrdering.ts
deleted file mode 100644
index 083f3680..00000000
--- a/src/util/migration/mysql/1696420827239-guildChannelOrdering.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class guildChannelOrdering1696420827239 implements MigrationInterface {
- name = "guildChannelOrdering1696420827239";
-
- public async up(queryRunner: QueryRunner): Promise {
- const guilds = await queryRunner.query(
- `SELECT id FROM guilds`,
- undefined,
- true,
- );
-
- await queryRunner.query(
- `ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`,
- );
-
- for (const guild_id of guilds.records.map((x) => x.id)) {
- const channels: Array<{ position: number; id: string }> = (
- await queryRunner.query(
- `SELECT id, position FROM channels WHERE guild_id = ?`,
- [guild_id],
- true,
- )
- ).records;
-
- channels.sort((a, b) => a.position - b.position);
-
- await queryRunner.query(
- `UPDATE guilds SET channel_ordering = ? WHERE id = ?`,
- [JSON.stringify(channels.map((x) => x.id)), guild_id],
- );
- }
-
- await queryRunner.query(`ALTER TABLE channels DROP COLUMN position`);
- }
-
- public async down(): Promise {
- // don't care actually, sorry.
- }
-}
diff --git a/src/util/migration/mysql/1713116476900-messageFlagsNotNull.ts b/src/util/migration/mysql/1713116476900-messageFlagsNotNull.ts
deleted file mode 100644
index 7be2ad70..00000000
--- a/src/util/migration/mysql/1713116476900-messageFlagsNotNull.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class MessageFlagsNotNull1713116476900 implements MigrationInterface {
- name = "MessageFlagsNotNull1713116476900";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` CHANGE flags flags_old integer;",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` ADD flags integer NOT NULL DEFAULT 0;",
- );
- await queryRunner.query(
- "UPDATE `messages` SET flags = IFNULL(flags_old, 0);",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` DROP COLUMN flags_old;",
- );
- }
-
- public async down(): Promise {
- // dont care
- throw new Error("Migration down is not implemented.");
- }
-}
diff --git a/src/util/migration/mysql/1719776735000-newUserSettings.ts b/src/util/migration/mysql/1719776735000-newUserSettings.ts
deleted file mode 100644
index f7c37ca9..00000000
--- a/src/util/migration/mysql/1719776735000-newUserSettings.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class NewUserSettings1719776735000 implements MigrationInterface {
- name = "NewUserSettings1719776735000";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `user_settings` ADD friend_discovery_flags integer NULL DEFAULT 0;",
- );
- await queryRunner.query(
- "ALTER TABLE `user_settings` ADD view_nsfw_guilds tinyint NULL DEFAULT 1;",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `user_settings` DROP COLUMN friend_discovery_flags;",
- );
- await queryRunner.query(
- "ALTER TABLE `user_settings` DROP COLUMN view_nsfw_guilds;",
- );
- }
-}
diff --git a/src/util/migration/mysql/1720157926878-messagePollObject.ts b/src/util/migration/mysql/1720157926878-messagePollObject.ts
deleted file mode 100644
index c0866426..00000000
--- a/src/util/migration/mysql/1720157926878-messagePollObject.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class MessagePollObject1720157926878 implements MigrationInterface {
- name = "MessagePollObject1720157926878";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `messages` ADD `poll` text NULL");
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `poll`");
- }
-}
diff --git a/src/util/migration/mysql/1720628601997-badges.ts b/src/util/migration/mysql/1720628601997-badges.ts
deleted file mode 100644
index af298e42..00000000
--- a/src/util/migration/mysql/1720628601997-badges.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class Badges1720628601997 implements MigrationInterface {
- name = "Badges1720628601997";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `CREATE TABLE \`badges\` (\`id\` varchar(255) NOT NULL, \`description\` varchar(255) NOT NULL, \`icon\` varchar(255) NOT NULL, \`link\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`,
- );
- await queryRunner.query(
- `ALTER TABLE \`users\` ADD \`badge_ids\` text NULL`,
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- `ALTER TABLE \`users\` DROP COLUMN \`badge_ids\``,
- );
- await queryRunner.query(`DROP TABLE \`badges\``);
- }
-}
diff --git a/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts b/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts
deleted file mode 100644
index 775847e0..00000000
--- a/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class WebhookMessageProperties1721298824927
- implements MigrationInterface
-{
- name = "WebhookMessageProperties1721298824927";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` ADD `username` text NULL",
- );
- await queryRunner.query(
- "ALTER TABLE `messages` ADD `avatar` text NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `messages` DROP COLUMN `username`",
- );
- await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`");
- }
-}
diff --git a/src/util/migration/mysql/1723347738541-client_status.ts b/src/util/migration/mysql/1723347738541-client_status.ts
deleted file mode 100644
index 0e02c45e..00000000
--- a/src/util/migration/mysql/1723347738541-client_status.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class client_status1723347738541 implements MigrationInterface {
- name = "client_status1723347738541";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `sessions` ADD `client_status` text NULL AFTER `client_info`",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `sessions` DROP COLUMN `client_status`",
- );
- }
-}
diff --git a/src/util/migration/mysql/1723577874393-discoveryCategoryIcon.ts b/src/util/migration/mysql/1723577874393-discoveryCategoryIcon.ts
deleted file mode 100644
index 18bc0a77..00000000
--- a/src/util/migration/mysql/1723577874393-discoveryCategoryIcon.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class DiscoveryCategoryIcon1723577874393 implements MigrationInterface {
- name = "DiscoveryCategoryIcon1723577874393";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `categories` ADD `icon` text NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query("ALTER TABLE `categories` DROP COLUMN `icon`");
- }
-}
diff --git a/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts b/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts
deleted file mode 100644
index ac2b1799..00000000
--- a/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class WebhookSourceChannel1723644478176 implements MigrationInterface {
- name = "WebhookSourceChannel1723644478176";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`",
- );
- await queryRunner.query(
- "ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`",
- );
- await queryRunner.query(
- "ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`",
- );
- }
-}
diff --git a/src/util/migration/mysql/1724477620293-teamMemberRole.ts b/src/util/migration/mysql/1724477620293-teamMemberRole.ts
deleted file mode 100644
index ff4be7bf..00000000
--- a/src/util/migration/mysql/1724477620293-teamMemberRole.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class TeamMemberRole1724477620293 implements MigrationInterface {
- name = "TeamMemberRole1724477620293";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `team_members` ADD COLUMN `role` VARCHAR(255) NOT NULL AFTER `permissions`",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `team_members` DROP COLUMN `role`",
- );
- }
-}
diff --git a/src/util/migration/mysql/1725090962922-applicationProperties.ts b/src/util/migration/mysql/1725090962922-applicationProperties.ts
deleted file mode 100644
index 6ba9077c..00000000
--- a/src/util/migration/mysql/1725090962922-applicationProperties.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { MigrationInterface, QueryRunner } from "typeorm";
-
-export class ApplicationProperties1725090962922 implements MigrationInterface {
- name = "ApplicationProperties1725090962922";
-
- public async up(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `applications` ADD COLUMN `guild_id` VARCHAR(255) DEFAULT NULL",
- );
- await queryRunner.query(
- "ALTER TABLE `applications` ADD COLUMN `custom_install_url` TEXT DEFAULT NULL",
- );
- }
-
- public async down(queryRunner: QueryRunner): Promise {
- await queryRunner.query(
- "ALTER TABLE `applications` DROP COLUMN `guild_id`",
- );
- await queryRunner.query(
- "ALTER TABLE `applications` DROP COLUMN `custom_install_url`",
- );
- }
-}
diff --git a/src/util/util/Database.ts b/src/util/util/Database.ts
index 35a6d09f..50763dd9 100644
--- a/src/util/util/Database.ts
+++ b/src/util/util/Database.ts
@@ -26,7 +26,7 @@ import { Migration } from "../entities/Migration";
// UUID extension option is only supported with postgres
// We want to generate all id's with Snowflakes that's why we have our own BaseEntity class
-let dbConnection: DataSource | undefined;
+export let dbConnection: DataSource | undefined;
// For typeorm cli
if (!process.env) {
@@ -36,14 +36,14 @@ if (!process.env) {
const dbConnectionString =
process.env.DATABASE || path.join(process.cwd(), "database.db");
-const DatabaseType = dbConnectionString.includes("://")
+export const DatabaseType = dbConnectionString.includes("://")
? dbConnectionString.split(":")[0]?.replace("+srv", "")
: "sqlite";
const isSqlite = DatabaseType.includes("sqlite");
-const DataSourceOptions = new DataSource({
+export const DataSourceOptions = new DataSource({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore type 'string' is not 'mysql' | 'sqlite' | 'mariadb' | etc etc
+ //@ts-ignore type 'string' is not 'sqlite' | 'postgres' | etc etc
type: DatabaseType,
charset: "utf8mb4",
url: isSqlite ? undefined : dbConnectionString,
@@ -77,7 +77,7 @@ export async function initDatabase(): Promise {
}
if (!process.env.DB_SYNC) {
- const supported = ["mysql", "mariadb", "postgres", "sqlite"];
+ const supported = ["postgres", "sqlite"];
if (!supported.includes(DatabaseType)) {
console.log(
"[Database]" +
@@ -129,11 +129,6 @@ export async function initDatabase(): Promise {
return dbConnection;
}
-export { DataSourceOptions, DatabaseType, dbConnection };
-
export async function closeDatabase() {
await dbConnection?.destroy();
}
-
-export const dbEngine =
- "InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";