mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* Handling custom scope from UI instead of env and data migration for it * Implemented group sync in UI for SAML and also changed the border weak for default ToolJet theme on platform. * Restrict SAML config updates to 'saml' only * Fix the color of Appname for the dark mode * Fixing migration issue * Removed the consoles from migrations * Minor fixes for save changes * chore: update version to 3.20.40-lts across all components --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
import * as dotenv from 'dotenv';
|
|
import * as fs from 'fs';
|
|
import { filePathForEnvVars } from '../scripts/database-config-utils';
|
|
|
|
export class AddGroupSyncEnabledToSAMLConfigs1762960587101 implements MigrationInterface {
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
let data: any = process.env;
|
|
const envVarsFilePath = filePathForEnvVars(process.env.NODE_ENV);
|
|
|
|
if (fs.existsSync(envVarsFilePath)) {
|
|
const envFileContent = fs.readFileSync(envVarsFilePath);
|
|
const parsedEnvVars = dotenv.parse(envFileContent);
|
|
data = { ...data, ...parsedEnvVars };
|
|
}
|
|
|
|
const rawValue = data.DISABLE_SAML_GROUP_SYNC;
|
|
|
|
// Rule:
|
|
// DISABLE_SAML_GROUP_SYNC = "false" --> desiredBool = true
|
|
// otherwise → false
|
|
const desiredBool = rawValue === 'false';
|
|
const sqlBool = String(desiredBool);
|
|
|
|
// Update SAML
|
|
await queryRunner.query(`
|
|
UPDATE sso_configs
|
|
SET configs = jsonb_set(
|
|
configs::jsonb,
|
|
'{groupSyncEnabled}',
|
|
'${sqlBool}'::jsonb,
|
|
true
|
|
)
|
|
WHERE sso = 'saml'
|
|
AND NOT (configs::jsonb ? 'groupSyncEnabled');
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
UPDATE sso_configs
|
|
SET configs = configs::jsonb - 'groupSyncEnabled'
|
|
WHERE sso = 'saml';
|
|
`);
|
|
}
|
|
}
|