diff --git a/packages/backend/src/migration/1700623165718-add-note-userhost-id-idx.ts b/packages/backend/src/migration/1700623165718-add-note-userhost-id-idx.ts new file mode 100644 index 000000000..2ba5759a4 --- /dev/null +++ b/packages/backend/src/migration/1700623165718-add-note-userhost-id-idx.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddNoteIdUserhostIdx1700623165718 implements MigrationInterface { + name = 'AddNoteIdUserhostIdx1700623165718' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE INDEX "IDX_note_id_userHost" ON "note" ("id", "userHost") `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX "public"."IDX_note_id_userHost"`); + } +} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index 21a39aa01..4a50c556e 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -17,6 +17,7 @@ import { Channel } from "./channel.js"; @Index("IDX_NOTE_MENTIONS", { synchronize: false }) @Index("IDX_NOTE_VISIBLE_USER_IDS", { synchronize: false }) @Index("IDX_note_userId_id", ["userId", "id"]) +@Index("IDX_note_id_userHost", ["id", "userHost"]) export class Note { @PrimaryColumn(id()) public id: string;