Skip to content

Commit 60413be

Browse files
authored
[orgs] Add index for slug (#16920)
Part of #16856
1 parent 1555eaa commit 60413be

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2023 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+
const table = "d_b_team";
11+
const column = "slug";
12+
const idxSlug = "idx_slug";
13+
14+
export class OrganizationSlugIndex1679312926829 implements MigrationInterface {
15+
public async up(queryRunner: QueryRunner): Promise<void> {
16+
if (!(await indexExists(queryRunner, table, idxSlug))) {
17+
await queryRunner.query(`CREATE INDEX \`${idxSlug}\` ON \`${table}\` (${column})`);
18+
}
19+
}
20+
21+
public async down(queryRunner: QueryRunner): Promise<void> {
22+
await queryRunner.query(`DROP INDEX ${idxSlug} ON ${table};`);
23+
}
24+
}

0 commit comments

Comments
 (0)