diff --git a/components/gitpod-db/src/typeorm/entity/db-workspace.ts b/components/gitpod-db/src/typeorm/entity/db-workspace.ts index ff8e4ad337de07..fec2196d6266f4 100644 --- a/components/gitpod-db/src/typeorm/entity/db-workspace.ts +++ b/components/gitpod-db/src/typeorm/entity/db-workspace.ts @@ -68,6 +68,7 @@ export class DBWorkspace implements Workspace { }) shareable?: boolean; + @Index("ind_type") @Column({ default: "regular", }) diff --git a/components/gitpod-db/src/typeorm/migration/1647290507971-IndexWorkspaceType.ts b/components/gitpod-db/src/typeorm/migration/1647290507971-IndexWorkspaceType.ts new file mode 100644 index 00000000000000..06231adb3fa036 --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1647290507971-IndexWorkspaceType.ts @@ -0,0 +1,23 @@ +/** + * 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 IndexWorkspaceType1647290507971 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + const TABLE_NAME = "d_b_workspace"; + const TYPE_INDEX_NAME = "ind_type"; + if (!(await indexExists(queryRunner, TABLE_NAME, TYPE_INDEX_NAME))) { + await queryRunner.query(`CREATE INDEX ${TYPE_INDEX_NAME} ON ${TABLE_NAME} (type)`); + } + } + + public async down(queryRunner: QueryRunner): Promise { + } + +}