From 3e92f33f411cdabaa3d86990712f483235ebeb6a Mon Sep 17 00:00:00 2001 From: Milan Pavlik Date: Tue, 6 Sep 2022 19:15:24 +0000 Subject: [PATCH] [db] Add index to d_b_workspace_instance on startedTime & stoppingTime --- ...6-WorkspaceInstanceStartedStoppingIndex.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 components/gitpod-db/src/typeorm/migration/1664441455556-WorkspaceInstanceStartedStoppingIndex.ts diff --git a/components/gitpod-db/src/typeorm/migration/1664441455556-WorkspaceInstanceStartedStoppingIndex.ts b/components/gitpod-db/src/typeorm/migration/1664441455556-WorkspaceInstanceStartedStoppingIndex.ts new file mode 100644 index 00000000000000..e4ea977887491d --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1664441455556-WorkspaceInstanceStartedStoppingIndex.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +import { MigrationInterface, QueryRunner } from "typeorm"; +import { indexExists } from "./helper/helper"; + +export class WorkspaceInstanceStartedStoppingIndex1662491259313 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const TABLE_NAME = "d_b_workspace_instance"; + + const startedTimeIndex = "IDX_workspace_instance__started_time"; + if (!(await indexExists(queryRunner, TABLE_NAME, startedTimeIndex))) { + await queryRunner.query(`CREATE INDEX ${startedTimeIndex} ON ${TABLE_NAME} (startedTime)`); + } + + const stoppingTimeIndex = "IDX_workspace_instance__stopping_time"; + if (!(await indexExists(queryRunner, TABLE_NAME, stoppingTimeIndex))) { + await queryRunner.query(`CREATE INDEX ${stoppingTimeIndex} ON ${TABLE_NAME} (stoppingTime)`); + } + } + + public async down(queryRunner: QueryRunner): Promise {} +}