diff --git a/packages/backend/src/migration/1702680809638-add-note-createdat-userid-idx.ts b/packages/backend/src/migration/1702680809638-add-note-createdat-userid-idx.ts new file mode 100644 index 000000000..e38f9d1a4 --- /dev/null +++ b/packages/backend/src/migration/1702680809638-add-note-createdat-userid-idx.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddNoteCreatedatUseridIdx1702680809638 implements MigrationInterface { + name = 'AddNoteCreatedatUseridIdx1702680809638' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_note_createdAt_userId" ON "note" ("createdAt", "userId")`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_note_createdAt_userId"`); + } +} diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts index 886e6538f..8062cac51 100644 --- a/packages/backend/src/models/entities/note.ts +++ b/packages/backend/src/models/entities/note.ts @@ -18,6 +18,7 @@ import { Channel } from "./channel.js"; @Index("IDX_NOTE_VISIBLE_USER_IDS", { synchronize: false }) @Index("IDX_note_userId_id", ["userId", "id"]) @Index("IDX_note_id_userHost", ["id", "userHost"]) +@Index("IDX_note_createdAt_userId", ["createdAt", "userId"]) export class Note { @PrimaryColumn(id()) public id: string;