From 0923043a92884a766b04ac8c5d41027a56ec1009 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:53:21 +0200 Subject: [PATCH 1/3] Add migration for new user setting props --- .../mariadb/1719776735000-newUserSettings.ts | 23 +++++++++++++++++++ .../mysql/1719776735000-newUserSettings.ts | 23 +++++++++++++++++++ .../postgres/1719776735000-newUserSettings.ts | 23 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/util/migration/mariadb/1719776735000-newUserSettings.ts create mode 100644 src/util/migration/mysql/1719776735000-newUserSettings.ts create mode 100644 src/util/migration/postgres/1719776735000-newUserSettings.ts diff --git a/src/util/migration/mariadb/1719776735000-newUserSettings.ts b/src/util/migration/mariadb/1719776735000-newUserSettings.ts new file mode 100644 index 000000000..f7c37ca92 --- /dev/null +++ b/src/util/migration/mariadb/1719776735000-newUserSettings.ts @@ -0,0 +1,23 @@ +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/1719776735000-newUserSettings.ts b/src/util/migration/mysql/1719776735000-newUserSettings.ts new file mode 100644 index 000000000..f7c37ca92 --- /dev/null +++ b/src/util/migration/mysql/1719776735000-newUserSettings.ts @@ -0,0 +1,23 @@ +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/postgres/1719776735000-newUserSettings.ts b/src/util/migration/postgres/1719776735000-newUserSettings.ts new file mode 100644 index 000000000..4d0224f0f --- /dev/null +++ b/src/util/migration/postgres/1719776735000-newUserSettings.ts @@ -0,0 +1,23 @@ +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 COLUMN friend_discovery_flags integer DEFAULT 0;", + ); + await queryRunner.query( + "ALTER TABLE user_settings ADD COLUMN view_nsfw_guilds tinyint 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;", + ); + } +} From 63f2d10f0a3f3f84795a4ff89b5d3af1d7bd9a92 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:54:03 +0200 Subject: [PATCH 2/3] Prettier -.- --- src/util/entities/UserSettings.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts index 0d4b6a7b7..d3efe79b2 100644 --- a/src/util/entities/UserSettings.ts +++ b/src/util/entities/UserSettings.ts @@ -122,7 +122,6 @@ export class UserSettings extends BaseClassWithoutId { @Column({ nullable: true }) view_nsfw_guilds: boolean = true; - } interface CustomStatus { From 66845050c9ef2ef60267e6b031a94f14f8e4cc91 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:25:29 +0200 Subject: [PATCH 3/3] Fix Postgres column type (hopefully) --- src/util/migration/postgres/1719776735000-newUserSettings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/migration/postgres/1719776735000-newUserSettings.ts b/src/util/migration/postgres/1719776735000-newUserSettings.ts index 4d0224f0f..dbee0b0d5 100644 --- a/src/util/migration/postgres/1719776735000-newUserSettings.ts +++ b/src/util/migration/postgres/1719776735000-newUserSettings.ts @@ -8,7 +8,7 @@ export class NewUserSettings1719776735000 implements MigrationInterface { "ALTER TABLE user_settings ADD COLUMN friend_discovery_flags integer DEFAULT 0;", ); await queryRunner.query( - "ALTER TABLE user_settings ADD COLUMN view_nsfw_guilds tinyint DEFAULT 1;", + "ALTER TABLE user_settings ADD COLUMN view_nsfw_guilds boolean DEFAULT true;", ); }