Skip to content

Commit cd79cf3

Browse files
committed
[db] DBGitpodToken: drop deleted column (unused)
1 parent 8cf17b5 commit cd79cf3

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

components/gitpod-db/src/tables.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ export class GitpodTableDescriptionProvider implements TableDescriptionProvider
6262
primaryKeys: ["id"],
6363
timeColumn: "_lastModified",
6464
},
65-
{
66-
name: "d_b_gitpod_token",
67-
primaryKeys: ["tokenHash"],
68-
deletionColumn: "deleted",
69-
timeColumn: "_lastModified",
70-
dependencies: ["d_b_user"],
71-
},
7265
{
7366
name: "d_b_one_time_secret",
7467
primaryKeys: ["id"],

components/gitpod-db/src/typeorm/entity/db-gitpod-token.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,4 @@ export class DBGitpodToken implements GitpodToken {
3232

3333
@Column()
3434
created: string;
35-
36-
@Column()
37-
deleted?: boolean;
3835
}
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 { columnExists } from "./helper/helper";
9+
10+
const TABLE_NAME = "d_b_gitpod_token";
11+
const COLUMN_NAME = "deleted";
12+
13+
export class GitpodTokenDropDeleted1695821079717 implements MigrationInterface {
14+
public async up(queryRunner: QueryRunner): Promise<void> {
15+
if (await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME)) {
16+
await queryRunner.query(`ALTER TABLE \`${TABLE_NAME}\` DROP COLUMN \`${COLUMN_NAME}\`, ALGORITHM=INSTANT`);
17+
}
18+
}
19+
20+
public async down(queryRunner: QueryRunner): Promise<void> {
21+
if (!(await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME))) {
22+
await queryRunner.query(
23+
`ALTER TABLE \`${TABLE_NAME}\` ADD COLUMN \`${COLUMN_NAME}\` tinyint(4) NOT NULL DEFAULT '0', ALGORITHM=INSTANT`,
24+
);
25+
}
26+
}
27+
}

components/gitpod-db/src/typeorm/user-db-impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl<UserDB> implements Us
221221
} else {
222222
qBuilder.where("gitpodToken.tokenHash = :tokenHash", { tokenHash });
223223
}
224-
qBuilder.andWhere("gitpodToken.deleted <> TRUE");
225224
const token = await qBuilder.getOne();
226225
if (!token) {
227226
return;

components/gitpod-protocol/src/protocol.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,6 @@ export interface GitpodToken {
680680

681681
/** Created timestamp */
682682
created: string;
683-
684-
// token is deleted on the database and about to be collected by periodic deleter
685-
deleted?: boolean;
686683
}
687684

688685
export enum GitpodTokenType {

components/server/src/user/gitpod-token-service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class GitpodTokenService {
2121
async getGitpodTokens(requestorId: string, userId: string): Promise<GitpodToken[]> {
2222
await this.auth.checkPermissionOnUser(requestorId, "read_tokens", userId);
2323
const gitpodTokens = await this.userDB.findAllGitpodTokensOfUser(userId);
24-
return gitpodTokens.filter((v) => !v.deleted);
24+
return gitpodTokens;
2525
}
2626

2727
async generateNewGitpodToken(
@@ -56,9 +56,6 @@ export class GitpodTokenService {
5656
} catch (error) {
5757
log.error({ userId }, "failed to resolve gitpod token: ", error);
5858
}
59-
if (token?.deleted) {
60-
token = undefined;
61-
}
6259
return token;
6360
}
6461

0 commit comments

Comments
 (0)