diff --git a/components/gitpod-db/go/project.go b/components/gitpod-db/go/project.go index d0f2854277be84..73ccc103d01ead 100644 --- a/components/gitpod-db/go/project.go +++ b/components/gitpod-db/go/project.go @@ -28,9 +28,6 @@ type Project struct { UserID sql.NullString `gorm:"column:userId;type:char;size:36;" json:"userId"` MarkedDeleted bool `gorm:"column:markedDeleted;type:tinyint;default:0;" json:"markedDeleted"` - - // deleted is reserved for use by periodic deleter - _ bool `gorm:"column:deleted;type:tinyint;default:0;" json:"deleted"` } // TableName sets the insert table name for this struct type diff --git a/components/gitpod-db/go/project_test.go b/components/gitpod-db/go/project_test.go index 608bc990b0c8ff..ea2679c19d02e0 100644 --- a/components/gitpod-db/go/project_test.go +++ b/components/gitpod-db/go/project_test.go @@ -23,7 +23,6 @@ var projectJSON = map[string]interface{}{ "teamId": "0e433063-1358-4892-9ed2-68e273d17d07", "appInstallationId": "20446411", "creationTime": "2021-11-01T19:36:07.532Z", - "deleted": 0, "_lastModified": "2021-11-02 10:49:12.473658", "name": "gptest1-repo1-private", "markedDeleted": 1, @@ -49,7 +48,7 @@ func TestProject_ReadExistingRecords(t *testing.T) { func insertRawProject(t *testing.T, conn *gorm.DB, obj map[string]interface{}) uuid.UUID { columns := []string{ - "id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "deleted", "_lastModified", "name", "markedDeleted", "userId", "slug", "settings", + "id", "cloneUrl", "teamId", "appInstallationId", "creationTime", "_lastModified", "name", "markedDeleted", "userId", "slug", "settings", } statement := fmt.Sprintf(`INSERT INTO d_b_project (%s) VALUES ?;`, strings.Join(columns, ", ")) id := uuid.MustParse(obj["id"].(string)) diff --git a/components/gitpod-db/src/tables.ts b/components/gitpod-db/src/tables.ts index 94fd0b12601dc0..4928c44b387eec 100644 --- a/components/gitpod-db/src/tables.ts +++ b/components/gitpod-db/src/tables.ts @@ -86,12 +86,6 @@ export class GitpodTableDescriptionProvider implements TableDescriptionProvider deletionColumn: "deleted", timeColumn: "_lastModified", }, - { - name: "d_b_project_usage", - primaryKeys: ["projectId"], - deletionColumn: "deleted", - timeColumn: "_lastModified", - }, { name: "d_b_user_ssh_public_key", primaryKeys: ["id"], diff --git a/components/gitpod-db/src/typeorm/entity/db-project-usage.ts b/components/gitpod-db/src/typeorm/entity/db-project-usage.ts index a8626dbba38169..3e099f5a0cd434 100644 --- a/components/gitpod-db/src/typeorm/entity/db-project-usage.ts +++ b/components/gitpod-db/src/typeorm/entity/db-project-usage.ts @@ -19,8 +19,4 @@ export class DBProjectUsage { @Column("varchar") lastWorkspaceStart: string; - - // This column triggers the periodic deleter deletion mechanism. It's not intended for public consumption. - @Column() - deleted: boolean; } diff --git a/components/gitpod-db/src/typeorm/migration/1695821957148-ProjectUsageDropDeleted.ts b/components/gitpod-db/src/typeorm/migration/1695821957148-ProjectUsageDropDeleted.ts new file mode 100644 index 00000000000000..e183ddb62d30cd --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1695821957148-ProjectUsageDropDeleted.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2023 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License.AGPL.txt in the project root for license information. + */ + +import { MigrationInterface, QueryRunner } from "typeorm"; +import { columnExists } from "./helper/helper"; + +const TABLE_NAME = "d_b_project_usage"; +const COLUMN_NAME = "deleted"; + +export class ProjectUsageDropDeleted1695821957148 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + if (await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME)) { + await queryRunner.query(`ALTER TABLE \`${TABLE_NAME}\` DROP COLUMN \`${COLUMN_NAME}\`, ALGORITHM=INSTANT`); + } + } + + public async down(queryRunner: QueryRunner): Promise { + if (!(await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME))) { + await queryRunner.query( + `ALTER TABLE \`${TABLE_NAME}\` ADD COLUMN \`${COLUMN_NAME}\` tinyint(4) NOT NULL DEFAULT '0', ALGORITHM=INSTANT`, + ); + } + } +}