From 27c9cbc2f97879233c28e3f4a5d3960ec0f40f5f Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Thu, 12 Oct 2023 12:16:25 +0900 Subject: [PATCH] chore: remove userListUserId Denormalized field from MiUserListJoining --- .../migration/1696807733453-userListUserId.js | 22 ------------------- .../1696808725134-userListUserId-2.js | 16 -------------- .../backend/src/models/UserListJoining.ts | 7 ------ 3 files changed, 45 deletions(-) delete mode 100644 packages/backend/migration/1696807733453-userListUserId.js delete mode 100644 packages/backend/migration/1696808725134-userListUserId-2.js diff --git a/packages/backend/migration/1696807733453-userListUserId.js b/packages/backend/migration/1696807733453-userListUserId.js deleted file mode 100644 index f4ec58f36aa0..000000000000 --- a/packages/backend/migration/1696807733453-userListUserId.js +++ /dev/null @@ -1,22 +0,0 @@ - -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export class UserListUserId1696807733453 { - name = 'UserListUserId1696807733453' - - async up(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" ADD "userListUserId" character varying(32) NOT NULL DEFAULT ''`); - const memberships = await queryRunner.query(`SELECT "id", "userListId" FROM "user_list_membership"`); - for(let i = 0; i < memberships.length; i++) { - const userList = await queryRunner.query(`SELECT "userId" FROM "user_list" WHERE "id" = $1`, [memberships[i].userListId]); - await queryRunner.query(`UPDATE "user_list_membership" SET "userListUserId" = $1 WHERE "id" = $2`, [userList[0].userId, memberships[i].id]); - } - } - - async down(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" DROP COLUMN "userListUserId"`); - } -} diff --git a/packages/backend/migration/1696808725134-userListUserId-2.js b/packages/backend/migration/1696808725134-userListUserId-2.js deleted file mode 100644 index 22d8704a9bfa..000000000000 --- a/packages/backend/migration/1696808725134-userListUserId-2.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export class UserListUserId21696808725134 { - name = 'UserListUserId21696808725134' - - async up(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" ALTER COLUMN "userListUserId" DROP DEFAULT`); - } - - async down(queryRunner) { - await queryRunner.query(`ALTER TABLE "user_list_membership" ALTER COLUMN "userListUserId" SET DEFAULT ''`); - } -} diff --git a/packages/backend/src/models/UserListJoining.ts b/packages/backend/src/models/UserListJoining.ts index 8f6a4edc7c62..4918f2f70001 100644 --- a/packages/backend/src/models/UserListJoining.ts +++ b/packages/backend/src/models/UserListJoining.ts @@ -44,11 +44,4 @@ export class MiUserListJoining { }) @JoinColumn() public userList: MiUserList | null; - - //#region Denormalized fields - @Column({ - ...id(), - }) - public userListUserId: MiUser['id']; - //#endregion }