diff options
Diffstat (limited to 'util')
18 files changed, 2606 insertions, 134 deletions
diff --git a/util/src/config/types/DefaultsConfiguration.ts b/util/src/config/types/DefaultsConfiguration.ts index c3171a01..9b02a590 100644 --- a/util/src/config/types/DefaultsConfiguration.ts +++ b/util/src/config/types/DefaultsConfiguration.ts @@ -1,5 +1,6 @@ -import { GuildDefaults } from "."; +import { GuildDefaults, UserDefaults } from "."; export class DefaultsConfiguration { guild: GuildDefaults = new GuildDefaults(); + user: UserDefaults = new UserDefaults(); } \ No newline at end of file diff --git a/util/src/config/types/subconfigurations/defaults/UserDefaults.ts b/util/src/config/types/subconfigurations/defaults/UserDefaults.ts new file mode 100644 index 00000000..4481c011 --- /dev/null +++ b/util/src/config/types/subconfigurations/defaults/UserDefaults.ts @@ -0,0 +1,5 @@ +export class UserDefaults { + premium: boolean = false; + premium_type: number = 2; + verified: boolean = true; +} \ No newline at end of file diff --git a/util/src/config/types/subconfigurations/defaults/index.ts b/util/src/config/types/subconfigurations/defaults/index.ts index f40c5cd2..50258d1c 100644 --- a/util/src/config/types/subconfigurations/defaults/index.ts +++ b/util/src/config/types/subconfigurations/defaults/index.ts @@ -1 +1,2 @@ export * from "./GuildDefaults"; +export * from "./UserDefaults"; diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index 77a04350..d146e577 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -53,7 +53,7 @@ export class Guild extends BaseClass { afk_channel?: Channel; @Column({ nullable: true }) - afk_timeout?: number; + afk_timeout?: number = Config.get().defaults.guild.afkTimeout; // * commented out -> use owner instead // application id of the guild creator if it is bot-created @@ -71,7 +71,7 @@ export class Guild extends BaseClass { banner?: string; @Column({ nullable: true }) - default_message_notifications?: number; + default_message_notifications?: number = Config.get().defaults.guild.defaultMessageNotifications; @Column({ nullable: true }) description?: string; @@ -80,7 +80,7 @@ export class Guild extends BaseClass { discovery_splash?: string; @Column({ nullable: true }) - explicit_content_filter?: number; + explicit_content_filter?: number = Config.get().defaults.guild.explicitContentFilter; @Column({ type: "simple-array" }) features: string[]; //TODO use enum @@ -96,19 +96,19 @@ export class Guild extends BaseClass { large?: boolean; @Column({ nullable: true }) - max_members?: number; // e.g. default 100.000 + max_members?: number = Config.get().limits.guild.maxMembers; // e.g. default 100.000 @Column({ nullable: true }) - max_presences?: number; + max_presences?: number = Config.get().defaults.guild.maxPresences; @Column({ nullable: true }) - max_video_channel_users?: number; // ? default: 25, is this max 25 streaming or watching + max_video_channel_users?: number = Config.get().defaults.guild.maxVideoChannelUsers; // ? default: 25, is this max 25 streaming or watching @Column({ nullable: true }) - member_count?: number; + member_count?: number = 0; @Column({ nullable: true }) - presence_count?: number; // users online + presence_count?: number = 0; // users online @OneToMany(() => Member, (member: Member) => member.guild, { cascade: true, @@ -278,6 +278,10 @@ export class Guild extends BaseClass { // only for developer portal permissions?: number; + //new guild settings, 11/08/2022: + @Column({ nullable: true }) + premium_progress_bar_enabled: boolean = false; + static async createGuild(body: { name?: string; icon?: string | null; diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index a9f00b0d..6edcda97 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -1,11 +1,11 @@ -import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany } from "typeorm"; +import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany, OneToOne } from "typeorm"; import { OrmUtils } from "../util/imports/OrmUtils"; import { BaseClass } from "./BaseClass"; import { BitField } from "../util/BitField"; import { Relationship } from "./Relationship"; import { ConnectedAccount } from "./ConnectedAccount"; import { Config, FieldErrors, Snowflake, trimSpecial } from ".."; -import { Member, Session } from "."; +import { Member, Session, UserSettings } from "."; export enum PublicUserEnum { username, @@ -83,28 +83,28 @@ export class User extends BaseClass { phone?: string; // phone number of the user @Column({ select: false }) - desktop: boolean; // if the user has desktop app installed + desktop: boolean = false; // if the user has desktop app installed @Column({ select: false }) - mobile: boolean; // if the user has mobile app installed + mobile: boolean = false; // if the user has mobile app installed @Column() - premium: boolean; // if user bought individual premium + premium: boolean = Config.get().defaults.user.premium; // if user bought individual premium @Column() - premium_type: number; // individual premium level + premium_type: number = Config.get().defaults.user.premium_type; // individual premium level @Column() - bot: boolean; // if user is bot + bot: boolean = false; // if user is bot @Column() bio: string; // short description of the user (max 190 chars -> should be configurable) @Column() - system: boolean; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author + system: boolean = false; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author @Column({ select: false }) - nsfw_allowed: boolean; // if the user can do age-restricted actions (NSFW channels/guilds/commands) + nsfw_allowed: boolean = true; // if the user can do age-restricted actions (NSFW channels/guilds/commands) // TODO: depending on age @Column({ select: false }) mfa_enabled: boolean; // if multi factor authentication is enabled @@ -116,31 +116,31 @@ export class User extends BaseClass { totp_last_ticket?: string; @Column() - created_at: Date; // registration date + created_at: Date = new Date(); // registration date @Column({ nullable: true }) - premium_since: Date; // premium date + premium_since: Date = new Date(); // premium date @Column({ select: false }) - verified: boolean; // if the user is offically verified + verified: boolean = Config.get().defaults.user.verified; // if the user is offically verified @Column() - disabled: boolean; // if the account is disabled + disabled: boolean = false; // if the account is disabled @Column() - deleted: boolean; // if the user was deleted + deleted: boolean = false; // if the user was deleted @Column({ nullable: true, select: false }) email?: string; // email of the user @Column() - flags: string; // UserFlags + flags: string = "0"; // UserFlags // TODO: generate @Column() - public_flags: number; + public_flags: number = 0; @Column({ type: "bigint" }) - rights: string; // Rights + rights: string = Config.get().register.defaultRights; // Rights @OneToMany(() => Session, (session: Session) => session.user) sessions: Session[]; @@ -166,17 +166,28 @@ export class User extends BaseClass { }; @Column({ type: "simple-array", select: false }) - fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts + fingerprints: string[] = []; // array of fingerprints -> used to prevent multiple accounts - @Column({ type: "simple-json", select: false }) + + @OneToOne(()=> UserSettings, { + cascade: true, + orphanedRowAction: "delete", + eager: false + }) + @JoinColumn() settings: UserSettings; // workaround to prevent fossord-unaware clients from deleting settings not used by them @Column({ type: "simple-json", select: false }) - extended_settings: string; + extended_settings: string = "{}"; @Column({ type: "simple-json" }) - notes: { [key: string]: string }; //key is ID of user + notes: { [key: string]: string } = {}; //key is ID of user + + async save(): Promise<any> { + await this.settings.save(); + return this.save(); + } toPublicUser() { const user: any = {}; @@ -256,40 +267,20 @@ export class User extends BaseClass { const language = req?.language === "en" ? "en-US" : req?.language || "en-US"; const user = OrmUtils.mergeDeep(new User(), { - created_at: new Date(), + //required: username: username, discriminator, id: Snowflake.generate(), - bot: false, - system: false, - premium_since: new Date(), - desktop: false, - mobile: false, - premium: true, - premium_type: 2, - bio: "", - mfa_enabled: false, - totp_secret: "", - totp_backup_codes: [], - verified: true, - disabled: false, - deleted: false, email: email, - rights: Config.get().register.defaultRights, // TODO: grant rights correctly, as 0 actually stands for no rights at all - nsfw_allowed: true, // TODO: depending on age - public_flags: "0", - flags: "0", // TODO: generate data: { hash: password, valid_tokens_since: new Date(), }, - settings: { ...defaultSettings, locale: language }, - extended_settings: {}, - fingerprints: [], - notes: {}, + settings: { ...new UserSettings(), locale: language } }); await user.save(); + await user.settings.save(); setImmediate(async () => { if (Config.get().guild.autoJoin.enabled) { @@ -303,85 +294,6 @@ export class User extends BaseClass { } } -export const defaultSettings: UserSettings = { - afk_timeout: 3600, - allow_accessibility_detection: true, - animate_emoji: true, - animate_stickers: 0, - contact_sync_enabled: false, - convert_emoticons: false, - custom_status: null, - default_guilds_restricted: false, - detect_platform_accounts: false, - developer_mode: true, - disable_games_tab: true, - enable_tts_command: false, - explicit_content_filter: 0, - friend_source_flags: { all: true }, - gateway_connected: false, - gif_auto_play: true, - guild_folders: [], - guild_positions: [], - inline_attachment_media: true, - inline_embed_media: true, - locale: "en-US", - message_display_compact: false, - native_phone_integration_enabled: true, - render_embeds: true, - render_reactions: true, - restricted_guilds: [], - show_current_game: true, - status: "online", - stream_notifications_enabled: false, - theme: "dark", - timezone_offset: 0, // TODO: timezone from request -}; - -export interface UserSettings { - afk_timeout: number; - allow_accessibility_detection: boolean; - animate_emoji: boolean; - animate_stickers: number; - contact_sync_enabled: boolean; - convert_emoticons: boolean; - custom_status: { - emoji_id?: string; - emoji_name?: string; - expires_at?: number; - text?: string; - } | null; - default_guilds_restricted: boolean; - detect_platform_accounts: boolean; - developer_mode: boolean; - disable_games_tab: boolean; - enable_tts_command: boolean; - explicit_content_filter: number; - friend_source_flags: { all: boolean }; - gateway_connected: boolean; - gif_auto_play: boolean; - // every top guild is displayed as a "folder" - guild_folders: { - color: number; - guild_ids: string[]; - id: number; - name: string; - }[]; - guild_positions: string[]; // guild ids ordered by position - inline_attachment_media: boolean; - inline_embed_media: boolean; - locale: string; // en_US - message_display_compact: boolean; - native_phone_integration_enabled: boolean; - render_embeds: boolean; - render_reactions: boolean; - restricted_guilds: string[]; - show_current_game: boolean; - status: "online" | "offline" | "dnd" | "idle" | "invisible"; - stream_notifications_enabled: boolean; - theme: "dark" | "white"; // dark - timezone_offset: number; // e.g -60 -} - export const CUSTOM_USER_FLAG_OFFSET = BigInt(1) << BigInt(32); export class UserFlags extends BitField { diff --git a/util/src/entities/UserSettings.ts b/util/src/entities/UserSettings.ts new file mode 100644 index 00000000..ef6f95af --- /dev/null +++ b/util/src/entities/UserSettings.ts @@ -0,0 +1,119 @@ +import { Column, Entity, JoinColumn } from "typeorm"; +import { BaseClassWithoutId, PrimaryIdColumn } from "."; + +@Entity("user_settings") +export class UserSettings extends BaseClassWithoutId { + @PrimaryIdColumn() + id: string; + + @Column({ nullable: true }) + afk_timeout: number = 3600; + + @Column({ nullable: true }) + allow_accessibility_detection: boolean = true; + + @Column({ nullable: true }) + animate_emoji: boolean = true; + + @Column({ nullable: true }) + animate_stickers: number = 0; + + @Column({ nullable: true }) + contact_sync_enabled: boolean = false; + + @Column({ nullable: true }) + convert_emoticons: boolean = false; + + @Column({ nullable: true, type: "simple-json" }) + custom_status: CustomStatus | null = null; + + @Column({ nullable: true }) + default_guilds_restricted: boolean = false; + + @Column({ nullable: true }) + detect_platform_accounts: boolean = false; + + @Column({ nullable: true }) + developer_mode: boolean = true; + + @Column({ nullable: true }) + disable_games_tab: boolean = true; + + @Column({ nullable: true }) + enable_tts_command: boolean = false; + + @Column({ nullable: true }) + explicit_content_filter: number = 0; + + @Column({ nullable: true, type: "simple-json" }) + friend_source_flags: FriendSourceFlags = { all: true }; + + @Column({ nullable: true }) + gateway_connected: boolean = false; + + @Column({ nullable: true }) + gif_auto_play: boolean = false; + + @Column({ nullable: true, type: "simple-json" }) + guild_folders: GuildFolder[] = []; // every top guild is displayed as a "folder" + + @Column({ nullable: true, type: "simple-json" }) + guild_positions: string[] = []; // guild ids ordered by position + + @Column({ nullable: true }) + inline_attachment_media: boolean = true; + + @Column({ nullable: true }) + inline_embed_media: boolean = true; + + @Column({ nullable: true }) + locale: string = "en-US"; // en_US + + @Column({ nullable: true }) + message_display_compact: boolean = false; + + @Column({ nullable: true }) + native_phone_integration_enabled: boolean = true; + + @Column({ nullable: true }) + render_embeds: boolean = true; + + @Column({ nullable: true }) + render_reactions: boolean = true; + + @Column({ nullable: true, type: "simple-json" }) + restricted_guilds: string[] = []; + + @Column({ nullable: true }) + show_current_game: boolean = true; + + @Column({ nullable: true }) + status: "online" | "offline" | "dnd" | "idle" | "invisible" = "online"; + + @Column({ nullable: true }) + stream_notifications_enabled: boolean = false; + + @Column({ nullable: true }) + theme: "dark" | "white" = "dark"; // dark + + @Column({ nullable: true }) + timezone_offset: number = 0; // e.g -60 +} + +interface CustomStatus { + emoji_id?: string; + emoji_name?: string; + expires_at?: number; + text?: string; +} + +interface GuildFolder { + color: number; + guild_ids: string[]; + id: number; + name: string; +} + +interface FriendSourceFlags { + all: boolean +} \ No newline at end of file diff --git a/util/src/entities/index.ts b/util/src/entities/index.ts index c439a4b7..c6f12022 100644 --- a/util/src/entities/index.ts +++ b/util/src/entities/index.ts @@ -30,3 +30,4 @@ export * from "./Webhook"; export * from "./ClientRelease"; export * from "./BackupCodes"; export * from "./Note"; +export * from "./UserSettings"; diff --git a/util/src/interfaces/Event.ts b/util/src/interfaces/Event.ts index f3391c4f..be66c62f 100644 --- a/util/src/interfaces/Event.ts +++ b/util/src/interfaces/Event.ts @@ -1,4 +1,4 @@ -import { PublicUser, User, UserSettings } from "../entities/User"; +import { PublicUser, User } from "../entities/User"; import { Channel } from "../entities/Channel"; import { Guild } from "../entities/Guild"; import { Member, PublicMember, UserGuildSettings } from "../entities/Member"; @@ -12,7 +12,7 @@ import { Interaction } from "./Interaction"; import { ConnectedAccount } from "../entities/ConnectedAccount"; import { Relationship, RelationshipType } from "../entities/Relationship"; import { Presence } from "./Presence"; -import { Sticker } from ".."; +import { Sticker, UserSettings } from ".."; import { Activity, Status } from "."; export interface Event { diff --git a/util/src/migrations/mariadb/1660258393551-CodeCleanup3.ts b/util/src/migrations/mariadb/1660258393551-CodeCleanup3.ts new file mode 100644 index 00000000..87d075e4 --- /dev/null +++ b/util/src/migrations/mariadb/1660258393551-CodeCleanup3.ts @@ -0,0 +1,232 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup31660258393551 implements MigrationInterface { + name = 'CodeCleanup31660258393551' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\` + `); + await queryRunner.query(` + DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` + `); + await queryRunner.query(` + CREATE TABLE \`user_settings\` ( + \`id\` varchar(255) NOT NULL, + \`afk_timeout\` int NULL, + \`allow_accessibility_detection\` tinyint NULL, + \`animate_emoji\` tinyint NULL, + \`animate_stickers\` int NULL, + \`contact_sync_enabled\` tinyint NULL, + \`convert_emoticons\` tinyint NULL, + \`custom_status\` text NULL, + \`default_guilds_restricted\` tinyint NULL, + \`detect_platform_accounts\` tinyint NULL, + \`developer_mode\` tinyint NULL, + \`disable_games_tab\` tinyint NULL, + \`enable_tts_command\` tinyint NULL, + \`explicit_content_filter\` int NULL, + \`friend_source_flags\` text NULL, + \`gateway_connected\` tinyint NULL, + \`gif_auto_play\` tinyint NULL, + \`guild_folders\` text NULL, + \`guild_positions\` text NULL, + \`inline_attachment_media\` tinyint NULL, + \`inline_embed_media\` tinyint NULL, + \`locale\` varchar(255) NULL, + \`message_display_compact\` tinyint NULL, + \`native_phone_integration_enabled\` tinyint NULL, + \`render_embeds\` tinyint NULL, + \`render_reactions\` tinyint NULL, + \`restricted_guilds\` text NULL, + \`show_current_game\` tinyint NULL, + \`status\` varchar(255) NULL, + \`stream_notifications_enabled\` tinyint NULL, + \`theme\` varchar(255) NULL, + \`timezone_offset\` int NULL, + PRIMARY KEY (\`id\`) + ) ENGINE = InnoDB + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP COLUMN \`settings\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`type\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`hook\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`verification_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`integration_public\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`tags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`install_params\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\` + `); + await queryRunner.query(` + ALTER TABLE \`guilds\` + ADD \`premium_progress_bar_enabled\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`rpc_origins\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`primary_sku_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`slug\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`guild_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`flags\` varchar(255) NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`flags\` int NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`guild_id\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`slug\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\` + `); + await queryRunner.query(` + ALTER TABLE \`guilds\` DROP COLUMN \`premium_progress_bar_enabled\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`bot_user_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`install_params\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`tags\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`discovery_eligibility_flags\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`discoverability_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`integration_require_code_grant\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`integration_public\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`interactions_endpoint_url\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`verification_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`store_application_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`rpc_application_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`redirect_uris\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`hook\` tinyint NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`type\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD \`settings\` text NOT NULL + `); + await queryRunner.query(` + DROP TABLE \`user_settings\` + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + +} diff --git a/util/src/migrations/mariadb/1660260587556-CodeCleanup4.ts b/util/src/migrations/mariadb/1660260587556-CodeCleanup4.ts new file mode 100644 index 00000000..98da67db --- /dev/null +++ b/util/src/migrations/mariadb/1660260587556-CodeCleanup4.ts @@ -0,0 +1,39 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260587556 implements MigrationInterface { + name = 'CodeCleanup41660260587556' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`users\` + ADD \`settingsId\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` (\`settingsId\`) + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`) + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD CONSTRAINT \`FK_76ba283779c8441fd5ff819c8cf\` FOREIGN KEY (\`settingsId\`) REFERENCES \`user_settings\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`users\` DROP FOREIGN KEY \`FK_76ba283779c8441fd5ff819c8cf\` + `); + await queryRunner.query(` + DROP INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP COLUMN \`settingsId\` + `); + } + +} diff --git a/util/src/migrations/postgres/1660257815436-CodeCleanup2.ts b/util/src/migrations/postgres/1660257815436-CodeCleanup2.ts new file mode 100644 index 00000000..511c2f5a --- /dev/null +++ b/util/src/migrations/postgres/1660257815436-CodeCleanup2.ts @@ -0,0 +1,59 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup21660257815436 implements MigrationInterface { + name = 'CodeCleanup21660257815436' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "user_settings" ( + "id" character varying NOT NULL, + "afk_timeout" integer, + "allow_accessibility_detection" boolean, + "animate_emoji" boolean, + "animate_stickers" integer, + "contact_sync_enabled" boolean, + "convert_emoticons" boolean, + "custom_status" text, + "default_guilds_restricted" boolean, + "detect_platform_accounts" boolean, + "developer_mode" boolean, + "disable_games_tab" boolean, + "enable_tts_command" boolean, + "explicit_content_filter" integer, + "friend_source_flags" text, + "gateway_connected" boolean, + "gif_auto_play" boolean, + "guild_folders" text, + "guild_positions" text, + "inline_attachment_media" boolean, + "inline_embed_media" boolean, + "locale" character varying, + "message_display_compact" boolean, + "native_phone_integration_enabled" boolean, + "render_embeds" boolean, + "render_reactions" boolean, + "restricted_guilds" text, + "show_current_game" boolean, + "status" character varying, + "stream_notifications_enabled" boolean, + "theme" character varying, + "timezone_offset" integer, + CONSTRAINT "PK_00f004f5922a0744d174530d639" PRIMARY KEY ("id") + ) + `); + await queryRunner.query(` + ALTER TABLE "guilds" + ADD "premium_progress_bar_enabled" boolean + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" DROP COLUMN "premium_progress_bar_enabled" + `); + await queryRunner.query(` + DROP TABLE "user_settings" + `); + } + +} diff --git a/util/src/migrations/postgres/1660258372154-CodeCleanup3.ts b/util/src/migrations/postgres/1660258372154-CodeCleanup3.ts new file mode 100644 index 00000000..e2823a54 --- /dev/null +++ b/util/src/migrations/postgres/1660258372154-CodeCleanup3.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup31660258372154 implements MigrationInterface { + name = 'CodeCleanup31660258372154' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" DROP COLUMN "settings" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ADD "settings" text NOT NULL + `); + } + +} diff --git a/util/src/migrations/postgres/1660260565996-CodeCleanup4.ts b/util/src/migrations/postgres/1660260565996-CodeCleanup4.ts new file mode 100644 index 00000000..0aaf7197 --- /dev/null +++ b/util/src/migrations/postgres/1660260565996-CodeCleanup4.ts @@ -0,0 +1,33 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260565996 implements MigrationInterface { + name = 'CodeCleanup41660260565996' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ADD "settingsId" character varying + `); + await queryRunner.query(` + ALTER TABLE "users" + ADD CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf" UNIQUE ("settingsId") + `); + await queryRunner.query(` + ALTER TABLE "users" + ADD CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings"("id") ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" DROP CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" + `); + await queryRunner.query(` + ALTER TABLE "users" DROP CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf" + `); + await queryRunner.query(` + ALTER TABLE "users" DROP COLUMN "settingsId" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660257576211-CodeCleanup1.ts b/util/src/migrations/sqlite/1660257576211-CodeCleanup1.ts new file mode 100644 index 00000000..5a61db0d --- /dev/null +++ b/util/src/migrations/sqlite/1660257576211-CodeCleanup1.ts @@ -0,0 +1,326 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup11660257576211 implements MigrationInterface { + name = 'CodeCleanup11660257576211' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "user_settings" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_timeout" integer, + "allow_accessibility_detection" boolean, + "animate_emoji" boolean, + "animate_stickers" integer, + "contact_sync_enabled" boolean, + "convert_emoticons" boolean, + "custom_status" text, + "default_guilds_restricted" boolean, + "detect_platform_accounts" boolean, + "developer_mode" boolean, + "disable_games_tab" boolean, + "enable_tts_command" boolean, + "explicit_content_filter" integer, + "friend_source_flags" text, + "gateway_connected" boolean, + "gif_auto_play" boolean, + "guild_folders" text, + "guild_positions" text, + "inline_attachment_media" boolean, + "inline_embed_media" boolean, + "locale" varchar, + "message_display_compact" boolean, + "native_phone_integration_enabled" boolean, + "render_embeds" boolean, + "render_reactions" boolean, + "restricted_guilds" text, + "show_current_game" boolean, + "status" varchar, + "stream_notifications_enabled" boolean, + "theme" varchar, + "timezone_offset" integer + ) + `); + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "user_settings" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660257795259-CodeCleanup2.ts b/util/src/migrations/sqlite/1660257795259-CodeCleanup2.ts new file mode 100644 index 00000000..53698256 --- /dev/null +++ b/util/src/migrations/sqlite/1660257795259-CodeCleanup2.ts @@ -0,0 +1,572 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup21660257795259 implements MigrationInterface { + name = 'CodeCleanup21660257795259' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660258351379-CodeCleanup3.ts b/util/src/migrations/sqlite/1660258351379-CodeCleanup3.ts new file mode 100644 index 00000000..13fba6dd --- /dev/null +++ b/util/src/migrations/sqlite/1660258351379-CodeCleanup3.ts @@ -0,0 +1,231 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup31660258351379 implements MigrationInterface { + name = 'CodeCleanup31660258351379' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "settings" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts b/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts new file mode 100644 index 00000000..d3f2a40d --- /dev/null +++ b/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts @@ -0,0 +1,459 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260539853 implements MigrationInterface { + name = 'CodeCleanup41660260539853' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), + CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660260672914-CodeCleanup4.ts b/util/src/migrations/sqlite/1660260672914-CodeCleanup4.ts new file mode 100644 index 00000000..33f4df03 --- /dev/null +++ b/util/src/migrations/sqlite/1660260672914-CodeCleanup4.ts @@ -0,0 +1,459 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260672914 implements MigrationInterface { + name = 'CodeCleanup41660260672914' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), + CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} |