2025-02-25 06:52:50 +00:00
|
|
|
import { GroupPermission } from '@entities/group_permission.entity';
|
2025-02-25 12:28:43 +00:00
|
|
|
import { TOOLJET_EDITIONS } from '@modules/app/constants';
|
2025-02-25 06:52:50 +00:00
|
|
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
2025-02-25 12:28:43 +00:00
|
|
|
import { getTooljetEdition } from '@helpers/utils.helper';
|
2025-02-25 06:52:50 +00:00
|
|
|
|
|
|
|
|
export class backfillDatasourceAdminPermissions1680789366109 implements MigrationInterface {
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
2025-02-25 12:28:43 +00:00
|
|
|
if (getTooljetEdition() === TOOLJET_EDITIONS.CE) {
|
2025-02-25 10:28:16 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2025-02-25 06:52:50 +00:00
|
|
|
const entityManager = queryRunner.manager;
|
|
|
|
|
const GroupPermissionRepository = entityManager.getRepository(GroupPermission);
|
|
|
|
|
|
|
|
|
|
await GroupPermissionRepository.update({ group: 'admin' }, { dataSourceCreate: true, dataSourceDelete: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
2025-02-25 12:28:43 +00:00
|
|
|
if (getTooljetEdition() === TOOLJET_EDITIONS.CE) {
|
2025-02-25 10:28:16 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2025-02-25 06:52:50 +00:00
|
|
|
const entityManager = queryRunner.manager;
|
|
|
|
|
const GroupPermissionRepository = entityManager.getRepository(GroupPermission);
|
|
|
|
|
|
|
|
|
|
await GroupPermissionRepository.update({ group: 'admin' }, { dataSourceCreate: false, dataSourceDelete: false });
|
|
|
|
|
}
|
|
|
|
|
}
|