Skip to content

Commit

Permalink
Create an index for contextURL column
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka authored and roboquat committed Feb 9, 2022
1 parent 5b57c9c commit e0f7bfe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/gitpod-db/src/typeorm/entity/db-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class DBWorkspace implements Workspace {
ownerId: string;

@Column("text")
@Index('ind_contextURL')
contextURL: string;

@Column({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 IndexWorkspaceContextUrl1644327547997 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
const TABLE_NAME = "d_b_workspace";
const INDEX_NAME = "ind_contextURL";

if(!(await indexExists(queryRunner, TABLE_NAME, INDEX_NAME))) {
await queryRunner.query("ALTER TABLE d_b_workspace MODIFY COLUMN `contextURL` varchar(255) NOT NULL");
await queryRunner.query(`CREATE INDEX ${INDEX_NAME} ON ${TABLE_NAME} (contextURL)`);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
}

}

0 comments on commit e0f7bfe

Please sign in to comment.