Skip to content

Commit 14a1ffd

Browse files
Andrew Farriesroboquat
Andrew Farries
authored andcommitted
Add uid column to d_b_oauth_auth_code_entry
This will become the new primary key in a subsequent migration.
1 parent 583831e commit 14a1ffd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
9+
const TABLE_NAME = "d_b_oauth_auth_code_entry";
10+
const COLUMN_NAME = "uid";
11+
12+
export class ChangeOauthCodePrimaryKey1664781308555 implements MigrationInterface {
13+
public async up(queryRunner: QueryRunner): Promise<void> {
14+
await queryRunner.query(
15+
`ALTER TABLE ${TABLE_NAME} ADD COLUMN ${COLUMN_NAME} char(36) NOT NULL DEFAULT '', ALGORITHM=INPLACE, LOCK=NONE`,
16+
);
17+
await queryRunner.query(`UPDATE ${TABLE_NAME} SET ${COLUMN_NAME}=(SELECT uuid());`);
18+
}
19+
20+
public async down(queryRunner: QueryRunner): Promise<void> {}
21+
}

0 commit comments

Comments
 (0)