Skip to content

Commit a3d51de

Browse files
committed
[db] DBProjectUsage: drop deleted column (unused)
1 parent 4622aea commit a3d51de

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

components/gitpod-db/src/tables.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ export class GitpodTableDescriptionProvider implements TableDescriptionProvider
8686
deletionColumn: "deleted",
8787
timeColumn: "_lastModified",
8888
},
89-
{
90-
name: "d_b_project_usage",
91-
primaryKeys: ["projectId"],
92-
deletionColumn: "deleted",
93-
timeColumn: "_lastModified",
94-
},
9589
{
9690
name: "d_b_user_ssh_public_key",
9791
primaryKeys: ["id"],

components/gitpod-db/src/typeorm/entity/db-project-usage.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ export class DBProjectUsage {
1919

2020
@Column("varchar")
2121
lastWorkspaceStart: string;
22-
23-
// This column triggers the periodic deleter deletion mechanism. It's not intended for public consumption.
24-
@Column()
25-
deleted: boolean;
2622
}
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_project_usage";
11+
const COLUMN_NAME = "deleted";
12+
13+
export class ProjectUsageDropDeleted1695821957148 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+
}

0 commit comments

Comments
 (0)