diff --git a/components/gitpod-db/src/tables.ts b/components/gitpod-db/src/tables.ts index 4928c44b387eec..0309f7c2e48707 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_user_ssh_public_key", - primaryKeys: ["id"], - deletionColumn: "deleted", - timeColumn: "_lastModified", - }, { name: "d_b_stripe_customer", primaryKeys: ["stripeCustomerId"], diff --git a/components/gitpod-db/src/typeorm/entity/db-user-ssh-public-key.ts b/components/gitpod-db/src/typeorm/entity/db-user-ssh-public-key.ts index bff7d40bd03d30..6452be4e6fd65f 100644 --- a/components/gitpod-db/src/typeorm/entity/db-user-ssh-public-key.ts +++ b/components/gitpod-db/src/typeorm/entity/db-user-ssh-public-key.ts @@ -49,8 +49,4 @@ export class DBUserSshPublicKey implements UserSSHPublicKey { transformer: Transformer.MAP_EMPTY_STR_TO_UNDEFINED, }) lastUsedTime?: 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/1695822248160-UserSshPublicKeyDropDeleted.ts b/components/gitpod-db/src/typeorm/migration/1695822248160-UserSshPublicKeyDropDeleted.ts new file mode 100644 index 00000000000000..f633c3e1f48537 --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1695822248160-UserSshPublicKeyDropDeleted.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_user_ssh_public_key"; +const COLUMN_NAME = "deleted"; + +export class UserSshPublicKeyDropDeleted1695822248160 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`, + ); + } + } +} diff --git a/components/gitpod-db/src/typeorm/user-db-impl.ts b/components/gitpod-db/src/typeorm/user-db-impl.ts index e13aa498a1735d..3ffd955b65e594 100644 --- a/components/gitpod-db/src/typeorm/user-db-impl.ts +++ b/components/gitpod-db/src/typeorm/user-db-impl.ts @@ -425,18 +425,18 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl implements Us public async hasSSHPublicKey(userId: string): Promise { const repo = await this.getSSHPublicKeyRepo(); - return !!(await repo.findOne({ where: { userId, deleted: false } })); + return !!(await repo.findOne({ where: { userId } })); } public async getSSHPublicKeys(userId: string): Promise { const repo = await this.getSSHPublicKeyRepo(); - return repo.find({ where: { userId, deleted: false }, order: { creationTime: "ASC" } }); + return repo.find({ where: { userId }, order: { creationTime: "ASC" } }); } public async addSSHPublicKey(userId: string, value: SSHPublicKeyValue): Promise { const repo = await this.getSSHPublicKeyRepo(); const fingerprint = SSHPublicKeyValue.getFingerprint(value); - const allKeys = await repo.find({ where: { userId, deleted: false } }); + const allKeys = await repo.find({ where: { userId } }); const prevOne = allKeys.find((e) => e.fingerprint === fingerprint); if (!!prevOne) { throw new Error(`Key already in use`);