diff --git a/components/gitpod-db/src/typeorm/team-db-impl.ts b/components/gitpod-db/src/typeorm/team-db-impl.ts index 460c120cda05c3..bc3866097ce1b6 100644 --- a/components/gitpod-db/src/typeorm/team-db-impl.ts +++ b/components/gitpod-db/src/typeorm/team-db-impl.ts @@ -377,19 +377,23 @@ export class TeamDBImpl extends TransactionalDBImpl implements TeamDB { public async setOrgSettings(orgId: string, settings: Partial): Promise { const repo = await this.getOrgSettingsRepo(); const team = await repo.findOne({ where: { orgId, deleted: false } }); + const update: Partial = {}; + if (settings.workspaceSharingDisabled != undefined) { + update.workspaceSharingDisabled = settings.workspaceSharingDisabled; + } + if (settings.defaultWorkspaceImage) { + update.defaultWorkspaceImage = settings.defaultWorkspaceImage; + } if (!team) { await repo.insert({ - ...settings, + ...update, orgId, }); } else { - if (settings.workspaceSharingDisabled) { - team.workspaceSharingDisabled = settings.workspaceSharingDisabled; - } - if (settings.defaultWorkspaceImage) { - team.defaultWorkspaceImage = settings.defaultWorkspaceImage; - } - repo.save(team); + repo.save({ + ...team, + ...update, + }); } }