diff --git a/components/gitpod-db/src/typeorm/entity/db-workspace-cluster.ts b/components/gitpod-db/src/typeorm/entity/db-workspace-cluster.ts index 831e2ffa41e989..cc8ab9b351d202 100644 --- a/components/gitpod-db/src/typeorm/entity/db-workspace-cluster.ts +++ b/components/gitpod-db/src/typeorm/entity/db-workspace-cluster.ts @@ -14,6 +14,7 @@ import { import { ValueTransformer } from "typeorm/decorator/options/ValueTransformer"; @Entity() +// on DB but not Typeorm: @Index("ind_lastModified", ["_lastModified"]) // DBSync export class DBWorkspaceCluster implements WorkspaceCluster { @PrimaryColumn() name: string; diff --git a/components/gitpod-db/src/typeorm/migration/1666616345054-AddLastModifiedToWorkspaceClusterTable.ts b/components/gitpod-db/src/typeorm/migration/1666616345054-AddLastModifiedToWorkspaceClusterTable.ts new file mode 100644 index 00000000000000..997c84f9409f83 --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1666616345054-AddLastModifiedToWorkspaceClusterTable.ts @@ -0,0 +1,22 @@ +/** + * 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"; + +const TABLE_NAME = "d_b_workspace_cluster"; +const COLUMN_NAME = "_lastModified"; +const INDEX_NAME = "ind_lastModified"; + +export class AddLastModifiedToWorkspaceClusterTable1666616345054 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE ${TABLE_NAME} ADD COLUMN ${COLUMN_NAME} timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), ALGORITHM=INPLACE, LOCK=NONE `, + ); + queryRunner.query(`CREATE INDEX ${INDEX_NAME} ON ${TABLE_NAME} (${COLUMN_NAME})`); + } + + public async down(queryRunner: QueryRunner): Promise {} +}