diff --git a/packages/backend/migration/1695861526125-index-note-userid.js b/packages/backend/migration/1695861526125-index-note-userid.js new file mode 100644 index 000000000..7fd991aef --- /dev/null +++ b/packages/backend/migration/1695861526125-index-note-userid.js @@ -0,0 +1,10 @@ +export class IndexNoteUserId1695861526125 { + name = "IndexNoteUserId1695861526125"; + async up(queryRunner) { + await queryRunner.query(`CREATE INDEX "IDX_note_userId_id" ON "note" ("userId", "id")`); + } + + async down(queryRunner) { + await queryRunner.query(`DROP INDEX "IDX_note_userId_id"`); + } +} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index edcfdb635..a844da509 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -16,6 +16,7 @@ import { Channel } from "./channel.js"; @Index("IDX_NOTE_TAGS", { synchronize: false }) @Index("IDX_NOTE_MENTIONS", { synchronize: false }) @Index("IDX_NOTE_VISIBLE_USER_IDS", { synchronize: false }) +@Index("IDX_note_userId_id", ["userId", "id"]) export class Note { @PrimaryColumn(id()) public id: string;