From 7986f934e6de6e8d28cf25219455feda3aecd35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Tue, 16 Jan 2024 05:53:58 +0900 Subject: [PATCH] =?UTF-8?q?Partially=20Revert=20'refactor:=20note=E3=83=86?= =?UTF-8?q?=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE=E3=82=A4=E3=83=B3=E3=83=87?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=B9=E6=95=B4=E7=90=86=E3=81=A8=E9=85=8D?= =?UTF-8?q?=E5=88=97=E3=82=AB=E3=83=A9=E3=83=A0=E3=81=B8=E3=81=AE=E3=82=AF?= =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=81=A7=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d92aaf81c42dc91a915d38168996536d19d36cf8 partially. Noteモデルの一部のB-TREEインデックスの定義を残すように --- ...222772858-optimize-note-index-for-array-column.js | 12 ++---------- packages/backend/src/models/Note.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/backend/migration/1705222772858-optimize-note-index-for-array-column.js b/packages/backend/migration/1705222772858-optimize-note-index-for-array-column.js index 571bd8e8f3..af71d5858c 100644 --- a/packages/backend/migration/1705222772858-optimize-note-index-for-array-column.js +++ b/packages/backend/migration/1705222772858-optimize-note-index-for-array-column.js @@ -7,18 +7,10 @@ export class OptimizeNoteIndexForArrayColumns1705222772858 { name = 'OptimizeNoteIndexForArrayColumns1705222772858' async up(queryRunner) { - await queryRunner.query(`DROP INDEX "public"."IDX_796a8c03959361f97dc2be1d5c"`); - await queryRunner.query(`DROP INDEX "public"."IDX_54ebcb6d27222913b908d56fd8"`); - await queryRunner.query(`DROP INDEX "public"."IDX_88937d94d7443d9a99a76fa5c0"`); - await queryRunner.query(`DROP INDEX "public"."IDX_51c063b6a133a9cb87145450f5"`); - await queryRunner.query(`CREATE INDEX "IDX_NOTE_FILE_IDS" ON "note" using gin ("fileIds")`) + await queryRunner.query(`CREATE INDEX "IDX_NOTE_FILE_IDS" ON "note" using gin ("fileIds")`); } async down(queryRunner) { - await queryRunner.query(`DROP INDEX "IDX_NOTE_FILE_IDS"`) - await queryRunner.query(`CREATE INDEX "IDX_51c063b6a133a9cb87145450f5" ON "note" ("fileIds") `); - await queryRunner.query(`CREATE INDEX "IDX_88937d94d7443d9a99a76fa5c0" ON "note" ("tags") `); - await queryRunner.query(`CREATE INDEX "IDX_54ebcb6d27222913b908d56fd8" ON "note" ("mentions") `); - await queryRunner.query(`CREATE INDEX "IDX_796a8c03959361f97dc2be1d5c" ON "note" ("visibleUserIds") `); + await queryRunner.query(`DROP INDEX "IDX_NOTE_FILE_IDS"`); } } diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index 27439282bc..856959cfc1 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -11,6 +11,10 @@ import { MiChannel } from './Channel.js'; import type { MiDriveFile } from './DriveFile.js'; @Entity('note') +@Index('IDX_NOTE_TAGS', { synchronize: false }) +@Index('IDX_NOTE_MENTIONS', { synchronize: false }) +@Index('IDX_NOTE_FILE_IDS', { synchronize: false }) +@Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false }) export class MiNote { @PrimaryColumn(id()) public id: string; @@ -137,7 +141,7 @@ export class MiNote { }) public url: string | null; - @Index('IDX_NOTE_FILE_IDS', { synchronize: false }) + @Index() @Column({ ...id(), array: true, default: '{}', @@ -149,14 +153,14 @@ export class MiNote { }) public attachedFileTypes: string[]; - @Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false }) + @Index() @Column({ ...id(), array: true, default: '{}', }) public visibleUserIds: MiUser['id'][]; - @Index('IDX_NOTE_MENTIONS', { synchronize: false }) + @Index() @Column({ ...id(), array: true, default: '{}', @@ -178,7 +182,7 @@ export class MiNote { }) public emojis: string[]; - @Index('IDX_NOTE_TAGS', { synchronize: false }) + @Index() @Column('varchar', { length: 128, array: true, default: '{}', })