From 8abffcbb6b24c60d0ad188cb59385b11f7cd6f4d Mon Sep 17 00:00:00 2001 From: Milan Pavlik Date: Thu, 1 Dec 2022 10:40:59 +0000 Subject: [PATCH] [pat] Apply on-update property to _lastModified column, remove from expirationTime --- ...nalAccessTokenFixLastModifiedAutoUpdate.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 components/gitpod-db/src/typeorm/migration/1669888999897-PersonalAccessTokenFixLastModifiedAutoUpdate.ts diff --git a/components/gitpod-db/src/typeorm/migration/1669888999897-PersonalAccessTokenFixLastModifiedAutoUpdate.ts b/components/gitpod-db/src/typeorm/migration/1669888999897-PersonalAccessTokenFixLastModifiedAutoUpdate.ts new file mode 100644 index 00000000000000..a1ab1f56dc6c2c --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1669888999897-PersonalAccessTokenFixLastModifiedAutoUpdate.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022 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"; + +const TABLE_NAME = "d_b_personal_access_token"; + +export class PersonalAccessTokenFixLastModifiedAutoUpdate1669888999897 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE ${TABLE_NAME} MODIFY expirationTime timestamp(6) NOT NULL`); + await queryRunner.query( + `ALTER TABLE ${TABLE_NAME} MODIFY _lastModified timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) on update CURRENT_TIMESTAMP(6)`, + ); + } + + public async down(queryRunner: QueryRunner): Promise {} +}