From 1b10022a1819827a313775565c5e6f2b3a2cff14 Mon Sep 17 00:00:00 2001 From: Huiwen Huang Date: Thu, 18 Jan 2024 15:25:34 +0000 Subject: [PATCH] Add admin role to builtin admin back --- .../1705591447620-AdminUserAddAdminRole.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 components/gitpod-db/src/typeorm/migration/1705591447620-AdminUserAddAdminRole.ts diff --git a/components/gitpod-db/src/typeorm/migration/1705591447620-AdminUserAddAdminRole.ts b/components/gitpod-db/src/typeorm/migration/1705591447620-AdminUserAddAdminRole.ts new file mode 100644 index 00000000000000..586bfaf2e2f4c5 --- /dev/null +++ b/components/gitpod-db/src/typeorm/migration/1705591447620-AdminUserAddAdminRole.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2024 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 { BUILTIN_INSTLLATION_ADMIN_USER_ID } from "../../user-db"; + +export class AdminUserAddAdminRole1705591447620 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `UPDATE d_b_user SET rolesOrPermissions = '["admin"]' WHERE id = '${BUILTIN_INSTLLATION_ADMIN_USER_ID}'`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `UPDATE d_b_user SET rolesOrPermissions = '[]' WHERE id = '${BUILTIN_INSTLLATION_ADMIN_USER_ID}'`, + ); + } +}