mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* Working on data-migration * Added entity file * Changing login-configs service functions * Changed some column names * Fixed updating and creating sso-configs * Changed the configs update and get apis & Worked on designs * Added frontend & server files * Working on oidc service * Fixed instance signup case * Fixed extra botton border issue * Fixed table updation issues * Added frontend and backend files * Added frontend commit file * Refactor role assignment condition in AuthUtilService * Update subproject commit reference in server/ee * Update subproject commit reference in server/ee * Fixed: no-permissioned group sync issues * Fixed: migrations * Fixed: editing the entity file * Fixed: migration null check * Updated subproject commit reference in server/ee * Updated subproject commit reference in server/ee
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import { EntityManager, MigrationInterface, QueryRunner } from 'typeorm';
|
|
import { processDataInBatches } from '@helpers/migration.helper';
|
|
import { SSOConfigs } from '@entities/sso_config.entity';
|
|
import { SsoConfigOidcGroupSync } from '@entities/sso_config_oidc_group_sync.entity';
|
|
|
|
export class MigrateGroupSyncData1752624000001 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
const entityManager = queryRunner.manager;
|
|
await processDataInBatches(
|
|
entityManager,
|
|
async (entityManager: EntityManager) => {
|
|
return await entityManager
|
|
.createQueryBuilder(SSOConfigs, 'sso_configs')
|
|
.select(['sso_configs.id', 'sso_configs.configs'])
|
|
.where('sso_configs.config_scope = :scope', { scope: 'organization' })
|
|
.andWhere('sso_configs.sso = :sso', { sso: 'openid' })
|
|
.getMany();
|
|
},
|
|
async (entityManager: EntityManager, ssoConfigs: SSOConfigs[]) => {
|
|
await this.processUpdates(entityManager, ssoConfigs);
|
|
},
|
|
100
|
|
);
|
|
}
|
|
|
|
private async processUpdates(entityManager: EntityManager, ssoConfigs: SSOConfigs[]) {
|
|
for (const config of ssoConfigs) {
|
|
const { id: ssoConfigId, configs } = config;
|
|
if (!configs) {
|
|
continue; // Skip if configs are not set or missing required fields
|
|
}
|
|
const { claimName, groupMapping, enableGroupSync } = configs as any;
|
|
|
|
const enrty = entityManager.create(SsoConfigOidcGroupSync, {
|
|
ssoConfigId,
|
|
organizationId: null,
|
|
claimName: claimName || null,
|
|
groupMapping: groupMapping || null,
|
|
enableGroupSync: enableGroupSync || false,
|
|
});
|
|
await entityManager.save(SsoConfigOidcGroupSync, enrty);
|
|
}
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
// Remove all rows from the sso_config_oidc_group_sync table
|
|
await queryRunner.query(`DELETE FROM sso_config_oidc_group_sync`);
|
|
}
|
|
}
|