Skip to content

Commit

Permalink
Add db migration (#19510)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 authored Mar 7, 2024
1 parent fbe03d4 commit 475be12
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/gitpod-db/src/typeorm/entity/db-team-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class DBOrgSettings implements OrganizationSettings {
@Column("json", { nullable: true })
allowedWorkspaceClasses?: string[] | null;

@Column("json", { nullable: true })
pinnedEditorVersions?: { [key: string]: string } | null;

@Column()
deleted: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 { columnExists } from "./helper/helper";

const table = "d_b_org_settings";
const newColumn = "pinnedEditorVersions";

export class AddPinnedEditorVersions1709626232691 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
if (!(await columnExists(queryRunner, table, newColumn))) {
await queryRunner.query(`ALTER TABLE ${table} ADD COLUMN ${newColumn} JSON NULL`);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
if (await columnExists(queryRunner, table, newColumn)) {
await queryRunner.query(`ALTER TABLE ${table} DROP COLUMN ${newColumn}`);
}
}
}
8 changes: 7 additions & 1 deletion components/gitpod-db/src/typeorm/team-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ export class TeamDBImpl extends TransactionalDBImpl<TeamDB> implements TeamDB {
const repo = await this.getOrgSettingsRepo();
return repo.findOne({
where: { orgId, deleted: false },
select: ["orgId", "workspaceSharingDisabled", "defaultWorkspaceImage", "allowedWorkspaceClasses"],
select: [
"orgId",
"workspaceSharingDisabled",
"defaultWorkspaceImage",
"allowedWorkspaceClasses",
"pinnedEditorVersions",
],
});
}

Expand Down
2 changes: 2 additions & 0 deletions components/gitpod-protocol/src/teams-projects-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export interface OrganizationSettings {

// empty array to allow all kind of workspace classes
allowedWorkspaceClasses?: string[] | null;

pinnedEditorVersions?: { [key: string]: string } | null;
}

export type TeamMemberRole = OrgMemberRole;
Expand Down

0 comments on commit 475be12

Please sign in to comment.