mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* Add option to enable and disable SSL in Postgres configuration UI * Connect to postgres with/without SSL based on user's choice * Add migration to set SSL enabled for every postgres data source * Fix data source kind name in migration * Fetch only postgres datasources in migration for turning on SSL
28 lines
968 B
TypeScript
28 lines
968 B
TypeScript
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
import { DataSource } from "../src/entities/data_source.entity";
|
|
|
|
export class TurnOnSSLForEveryPostgresDataSource1630003364070 implements MigrationInterface {
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
const entityManager = queryRunner.manager;
|
|
const queryBuilder = queryRunner.connection.createQueryBuilder();
|
|
const dataSourceRepository = entityManager.getRepository(DataSource);
|
|
|
|
const dataSources = await dataSourceRepository.find({ where: { kind: 'postgresql' } });
|
|
|
|
for(const dataSource of dataSources) {
|
|
const options = dataSource.options;
|
|
if(options) {
|
|
options['ssl_enabled'] = { value: true, encrypted: false };
|
|
await queryBuilder.update(DataSource)
|
|
.set({ options })
|
|
.where('id = :id', { id: dataSource.id })
|
|
.execute();
|
|
}
|
|
}
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
}
|
|
|
|
}
|