Skip to content

Commit 1e0a4ba

Browse files
Andrew Farriesroboquat
Andrew Farries
authored andcommitted
Add _lastModified column to d_b_workspace_cluster
So that it can be synced with `db-sync.`
1 parent 6722bd1 commit 1e0a4ba

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Diff for: components/gitpod-db/src/typeorm/entity/db-workspace-cluster.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { ValueTransformer } from "typeorm/decorator/options/ValueTransformer";
1515

1616
@Entity()
17+
// on DB but not Typeorm: @Index("ind_lastModified", ["_lastModified"]) // DBSync
1718
export class DBWorkspaceCluster implements WorkspaceCluster {
1819
@PrimaryColumn()
1920
name: string;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { MigrationInterface, QueryRunner } from "typeorm";
8+
9+
const TABLE_NAME = "d_b_workspace_cluster";
10+
const COLUMN_NAME = "_lastModified";
11+
const INDEX_NAME = "ind_lastModified";
12+
13+
export class AddLastModifiedToWorkspaceClusterTable1666616345054 implements MigrationInterface {
14+
public async up(queryRunner: QueryRunner): Promise<void> {
15+
await queryRunner.query(
16+
`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 `,
17+
);
18+
queryRunner.query(`CREATE INDEX ${INDEX_NAME} ON ${TABLE_NAME} (${COLUMN_NAME})`);
19+
}
20+
21+
public async down(queryRunner: QueryRunner): Promise<void> {}
22+
}

0 commit comments

Comments
 (0)