Skip to content

Commit e0f7bfe

Browse files
Laurie T. Malauroboquat
Laurie T. Malau
authored andcommitted
Create an index for contextURL column
1 parent 5b57c9c commit e0f7bfe

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

components/gitpod-db/src/typeorm/entity/db-workspace.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class DBWorkspace implements Workspace {
2727
ownerId: string;
2828

2929
@Column("text")
30+
@Index('ind_contextURL')
3031
contextURL: string;
3132

3233
@Column({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 { indexExists } from "./helper/helper";
9+
10+
export class IndexWorkspaceContextUrl1644327547997 implements MigrationInterface {
11+
12+
public async up(queryRunner: QueryRunner): Promise<void> {
13+
const TABLE_NAME = "d_b_workspace";
14+
const INDEX_NAME = "ind_contextURL";
15+
16+
if(!(await indexExists(queryRunner, TABLE_NAME, INDEX_NAME))) {
17+
await queryRunner.query("ALTER TABLE d_b_workspace MODIFY COLUMN `contextURL` varchar(255) NOT NULL");
18+
await queryRunner.query(`CREATE INDEX ${INDEX_NAME} ON ${TABLE_NAME} (contextURL)`);
19+
}
20+
}
21+
22+
public async down(queryRunner: QueryRunner): Promise<void> {
23+
}
24+
25+
}

0 commit comments

Comments
 (0)