Skip to content

Commit 83493bd

Browse files
authored
[db] Add index for user.verificationPhoneNumber (#18836)
1 parent 11fa2f3 commit 83493bd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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_NAME = "d_b_user";
11+
const INDEX_NAME = "ind_verificationPhoneNumber";
12+
13+
export class UserAddIndexVerificationPhoneNumber1695901995842 implements MigrationInterface {
14+
public async up(queryRunner: QueryRunner): Promise<void> {
15+
if (!(await indexExists(queryRunner, TABLE_NAME, INDEX_NAME))) {
16+
await queryRunner.query(
17+
`ALTER TABLE \`${TABLE_NAME}\` ADD INDEX \`${INDEX_NAME}\` (verificationPhoneNumber), ALGORITHM=INPLACE, LOCK=NONE`,
18+
);
19+
}
20+
}
21+
22+
public async down(queryRunner: QueryRunner): Promise<void> {
23+
if (await indexExists(queryRunner, TABLE_NAME, INDEX_NAME)) {
24+
await queryRunner.query(`DROP INDEX ${INDEX_NAME} ON ${TABLE_NAME}`);
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)