From 3f3d4c966ea63acca7a0543991a4f8ef6c1dee23 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 14 Aug 2020 15:24:55 +0900 Subject: [PATCH] perf(server): Add isSensitive index to improve query performance --- migration/1597385880794-add-sensitive-index.ts | 14 ++++++++++++++ src/models/entities/drive-file.ts | 1 + 2 files changed, 15 insertions(+) create mode 100644 migration/1597385880794-add-sensitive-index.ts diff --git a/migration/1597385880794-add-sensitive-index.ts b/migration/1597385880794-add-sensitive-index.ts new file mode 100644 index 000000000..ff6251ac0 --- /dev/null +++ b/migration/1597385880794-add-sensitive-index.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class addSensitiveIndex1597385880794 implements MigrationInterface { + name = 'addSensitiveIndex1597385880794' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE INDEX "IDX_a7eba67f8b3fa27271e85d2e26" ON "drive_file" ("isSensitive") `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX "IDX_a7eba67f8b3fa27271e85d2e26"`); + } + +} diff --git a/src/models/entities/drive-file.ts b/src/models/entities/drive-file.ts index c02b9f363..680a40bc0 100644 --- a/src/models/entities/drive-file.ts +++ b/src/models/entities/drive-file.ts @@ -145,6 +145,7 @@ export class DriveFile { @JoinColumn() public folder: DriveFolder | null; + @Index() @Column('boolean', { default: false, comment: 'Whether the DriveFile is NSFW.'