Skip to content

Commit 18943b2

Browse files
author
Laurie T. Malau
committed
[db] Create d_b_personal_access_token
1 parent 8aeb5e1 commit 18943b2

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) 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 { tableExists } from "./helper/helper";
9+
10+
export class CreatePersonalAccessTokenTable1668531007092 implements MigrationInterface {
11+
public async up(queryRunner: QueryRunner): Promise<void> {
12+
if (!(await tableExists(queryRunner, "d_b_personal_access_token"))) {
13+
await queryRunner.query(
14+
"CREATE TABLE IF NOT EXISTS `d_b_personal_access_token` (`id` varchar(255) NOT NULL, `userId` varchar(255) NOT NULL, `hash` varchar(255) NOT NULL, `name` varchar(255) NOT NULL, `description` text DEFAULT NULL, `scopes` text NOT NULL, `expirationTime` timestamp(6) NOT NULL, `createdAt` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), `_lastModified` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), `deleted` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (id))",
15+
);
16+
await queryRunner.query("CREATE INDEX `ind_userId` ON `d_b_personal_access_token` (userId)");
17+
await queryRunner.query("CREATE INDEX `ind_hash` ON `d_b_personal_access_token` (hash)");
18+
await queryRunner.query("CREATE INDEX `ind_lastModified` ON `d_b_personal_access_token` (_lastModified)");
19+
}
20+
}
21+
22+
public async down(queryRunner: QueryRunner): Promise<void> {
23+
if (await tableExists(queryRunner, "d_b_personal_access_token")) {
24+
await queryRunner.query("DROP TABLE `d_b_personal_access_token`");
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)