ToolJet/server/data-migrations/1764047424500-BackfillMongoDBDatasourceNewFields.ts
Pratush Sinha 861e717248
MongoDB connection with srv support (#14626)
* MongoDB connection with srv support

* design changes and migration

* changes in design

* fix password field is coming disabled.

* change with save button

* changes in the save button and encrypt

* Changes for mongoDb SRV after Code Review

* migration script

* Changes in the UI

* fixed the db issue in connection

* changes comment removed

* SSl issue resolved

* Review changes made

* editing connection string affects only individual fields

* fixed dataSource Saving in imported apps

* fixed imported apps ds save

---------

Co-authored-by: Pratush <pratush@Pratushs-MacBook-Pro.local>
2025-12-10 15:06:10 +05:30

26 lines
860 B
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
export class BackfillMongoDBDatasourceNewFields1764000000000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE data_source_options dso
SET "options" = (
"options"::jsonb
|| jsonb_build_object(
'connection_format',
COALESCE(("options"::jsonb -> 'connection_format'), jsonb_build_object('value','mongodb','encrypted',false)),
'use_ssl',
COALESCE(("options"::jsonb -> 'use_ssl'), jsonb_build_object('value', false, 'encrypted', false))
)
)::json
FROM data_sources ds
WHERE ds.id = dso.data_source_id
AND ds.kind = 'mongodb';
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}