From 52b0c6c8f8d5b16a95882c4b384555d43e587d74 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 16 Dec 2023 17:43:15 +0100 Subject: [PATCH] [backend] Add a new index to the user table for faster notifications queries This should drastically improve performance of the i/notification endpoint --- .../migration/1702744857694-user-issuspended-idx.ts | 13 +++++++++++++ packages/backend/src/models/entities/user.ts | 1 + 2 files changed, 14 insertions(+) create mode 100644 packages/backend/src/migration/1702744857694-user-issuspended-idx.ts diff --git a/packages/backend/src/migration/1702744857694-user-issuspended-idx.ts b/packages/backend/src/migration/1702744857694-user-issuspended-idx.ts new file mode 100644 index 000000000..86616e855 --- /dev/null +++ b/packages/backend/src/migration/1702744857694-user-issuspended-idx.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UserIssuspendedIdx1702744857694 implements MigrationInterface { + name = 'UserIssuspendedIdx1702744857694' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_8977c6037a7bc2cb0c84b6d4db" ON "user" ("isSuspended")`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_8977c6037a7bc2cb0c84b6d4db"`); + } +} diff --git a/packages/backend/src/models/entities/user.ts b/packages/backend/src/models/entities/user.ts index d7412500e..92de37e3f 100644 --- a/packages/backend/src/models/entities/user.ts +++ b/packages/backend/src/models/entities/user.ts @@ -158,6 +158,7 @@ export class User { }) public tags: string[]; + @Index() @Column("boolean", { default: false, comment: "Whether the User is suspended.",