Skip to content

Commit e33f34c

Browse files
committed
[db] fix d_b_workspace_instance_usage.startedAt and add ind_dbsync
1 parent 59e89b2 commit e33f34c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
import { columnExists } from "./helper/helper";
9+
10+
const TABLE_NAME = "d_b_workspace_instance_usage";
11+
const COLUMN_NAME = "startedAt";
12+
13+
export class WorkspaceInstanceUsageUpdate1662027342962 implements MigrationInterface {
14+
public async up(queryRunner: QueryRunner): Promise<void> {
15+
if (await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME)) {
16+
await queryRunner.query(
17+
`ALTER TABLE ${TABLE_NAME} CHANGE COLUMN ${COLUMN_NAME} timestamp(6) NULL, ALGORITHM=INPLACE, LOCK=NONE`,
18+
);
19+
}
20+
await queryRunner.query("CREATE INDEX `ind_dbsync` ON `d_b_workspace_instance_usage` (_lastModified)");
21+
}
22+
23+
public async down(queryRunner: QueryRunner): Promise<void> {
24+
await queryRunner.query("ALTER TABLE `d_b_workspace_instance_usage` DROP INDEX `ind_dbsync`");
25+
}
26+
}

0 commit comments

Comments
 (0)