Skip to content

Commit 0547c25

Browse files
committed
[db] DBProjectUsage: drop deleted column (unused)
1 parent 93ad9cf commit 0547c25

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

components/gitpod-db/go/project.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ type Project struct {
2828
UserID sql.NullString `gorm:"column:userId;type:char;size:36;" json:"userId"`
2929

3030
MarkedDeleted bool `gorm:"column:markedDeleted;type:tinyint;default:0;" json:"markedDeleted"`
31-
32-
// deleted is reserved for use by periodic deleter
33-
_ bool `gorm:"column:deleted;type:tinyint;default:0;" json:"deleted"`
3431
}
3532

3633
// TableName sets the insert table name for this struct type

components/gitpod-db/go/project_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var projectJSON = map[string]interface{}{
2323
"teamId": "0e433063-1358-4892-9ed2-68e273d17d07",
2424
"appInstallationId": "20446411",
2525
"creationTime": "2021-11-01T19:36:07.532Z",
26-
"deleted": 0,
2726
"_lastModified": "2021-11-02 10:49:12.473658",
2827
"name": "gptest1-repo1-private",
2928
"markedDeleted": 1,
@@ -49,7 +48,7 @@ func TestProject_ReadExistingRecords(t *testing.T) {
4948

5049
func insertRawProject(t *testing.T, conn *gorm.DB, obj map[string]interface{}) uuid.UUID {
5150
columns := []string{
52-
"id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "deleted", "_lastModified", "name", "markedDeleted", "userId", "slug", "settings",
51+
"id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "_lastModified", "name", "markedDeleted", "userId", "slug", "settings",
5352
}
5453
statement := fmt.Sprintf(`INSERT INTO d_b_project (%s) VALUES ?;`, strings.Join(columns, ", "))
5554
id := uuid.MustParse(obj["id"].(string))

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)