Partially Revert 'refactor: noteテーブルのインデックス整理と配列カラムへのクエリでインデックスを使うように'

This reverts commit d92aaf81c4 partially.

Noteモデルの一部のB-TREEインデックスの定義を残すように
This commit is contained in:
まっちゃとーにゅ 2024-01-16 05:53:58 +09:00
parent 47eaf0b446
commit 7986f934e6
No known key found for this signature in database
GPG Key ID: 143DE582A97FE052
2 changed files with 10 additions and 14 deletions

View File

@ -7,18 +7,10 @@ export class OptimizeNoteIndexForArrayColumns1705222772858 {
name = 'OptimizeNoteIndexForArrayColumns1705222772858' name = 'OptimizeNoteIndexForArrayColumns1705222772858'
async up(queryRunner) { async up(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_796a8c03959361f97dc2be1d5c"`); await queryRunner.query(`CREATE INDEX "IDX_NOTE_FILE_IDS" ON "note" using gin ("fileIds")`);
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")`)
} }
async down(queryRunner) { async down(queryRunner) {
await queryRunner.query(`DROP INDEX "IDX_NOTE_FILE_IDS"`) 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") `);
} }
} }

View File

@ -11,6 +11,10 @@ import { MiChannel } from './Channel.js';
import type { MiDriveFile } from './DriveFile.js'; import type { MiDriveFile } from './DriveFile.js';
@Entity('note') @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 { export class MiNote {
@PrimaryColumn(id()) @PrimaryColumn(id())
public id: string; public id: string;
@ -137,7 +141,7 @@ export class MiNote {
}) })
public url: string | null; public url: string | null;
@Index('IDX_NOTE_FILE_IDS', { synchronize: false }) @Index()
@Column({ @Column({
...id(), ...id(),
array: true, default: '{}', array: true, default: '{}',
@ -149,14 +153,14 @@ export class MiNote {
}) })
public attachedFileTypes: string[]; public attachedFileTypes: string[];
@Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false }) @Index()
@Column({ @Column({
...id(), ...id(),
array: true, default: '{}', array: true, default: '{}',
}) })
public visibleUserIds: MiUser['id'][]; public visibleUserIds: MiUser['id'][];
@Index('IDX_NOTE_MENTIONS', { synchronize: false }) @Index()
@Column({ @Column({
...id(), ...id(),
array: true, default: '{}', array: true, default: '{}',
@ -178,7 +182,7 @@ export class MiNote {
}) })
public emojis: string[]; public emojis: string[];
@Index('IDX_NOTE_TAGS', { synchronize: false }) @Index()
@Column('varchar', { @Column('varchar', {
length: 128, array: true, default: '{}', length: 128, array: true, default: '{}',
}) })