From 2c7c7700619c47379b3bc201837af5ff50d39e05 Mon Sep 17 00:00:00 2001 From: Gero Posmyk-Leinemann <32448529+geropl@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:05:06 +0200 Subject: [PATCH] [server, usage, db] Drop CostCenter.deleted (not used) (#18809) --- components/gitpod-db/src/tables.ts | 1 - .../1695735203768-CostCenterDropDeleted.ts | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 components/gitpod-db/src/typeorm/migration/1695735203768-CostCenterDropDeleted.ts diff --git a/components/gitpod-db/src/tables.ts b/components/gitpod-db/src/tables.ts index 100e0465070e6f..bd75e47912467a 100644 --- a/components/gitpod-db/src/tables.ts +++ b/components/gitpod-db/src/tables.ts @@ -201,7 +201,6 @@ export class GitpodTableDescriptionProvider implements TableDescriptionProvider { name: "d_b_cost_center", primaryKeys: ["id", "creationTime"], - deletionColumn: "deleted", timeColumn: "_lastModified", }, { diff --git a/components/gitpod-db/src/typeorm/migration/1695735203768-CostCenterDropDeleted.ts b/components/gitpod-db/src/typeorm/migration/1695735203768-CostCenterDropDeleted.ts new file mode 100644 index 00000000000000..7747344d6614df --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1695735203768-CostCenterDropDeleted.ts @@ -0,0 +1,24 @@ +/** + * 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"; + +export class CostCenterDropDeleted1695735203768 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + if (await columnExists(queryRunner, "d_b_cost_center", "deleted")) { + await queryRunner.query("ALTER TABLE `d_b_cost_center` DROP COLUMN `deleted`, ALGORITHM=INSTANT"); + } + } + + public async down(queryRunner: QueryRunner): Promise { + if (!(await columnExists(queryRunner, "d_b_cost_center", "deleted"))) { + await queryRunner.query( + "ALTER TABLE `d_b_cost_center` ADD COLUMN `deleted` tinyint(4) NOT NULL DEFAULT '0', ALGORITHM=INSTANT", + ); + } + } +}