ToolJet/server/migrations/1680152466161-CreateDatasourceGroupPermission.ts
Muhsin Shah C P d275a8ac58
[fix/modularisation] Fixed the white-label store helper issue and changed EDITION to TOOLJET_EDITION (#12044)
* Fixed: Changed EDITION to TOOLJEET_EDITION and fixed ee frontend helper file issue

* Changed the edition env in docker files
2025-02-25 17:58:43 +05:30

93 lines
2.4 KiB
TypeScript

import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
import { TOOLJET_EDITIONS } from '@modules/app/constants';
import { getTooljetEdition } from '@helpers/utils.helper';
export class CreateDatasourceGroupPermission1680152466161 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
if (getTooljetEdition() === TOOLJET_EDITIONS.CE) {
return;
}
await queryRunner.createTable(
new Table({
name: 'data_source_group_permissions',
columns: [
{
name: 'id',
type: 'uuid',
isGenerated: true,
default: 'gen_random_uuid()',
isPrimary: true,
},
{
name: 'data_source_id',
type: 'uuid',
isNullable: false,
},
{
name: 'group_permission_id',
type: 'uuid',
isNullable: false,
},
{
name: 'read',
type: 'boolean',
default: false,
isNullable: false,
},
{
name: 'update',
type: 'boolean',
default: false,
isNullable: false,
},
{
name: 'delete',
type: 'boolean',
default: false,
isNullable: false,
},
{
name: 'created_at',
type: 'timestamp',
isNullable: false,
default: 'now()',
},
{
name: 'updated_at',
type: 'timestamp',
isNullable: false,
default: 'now()',
},
],
}),
true
);
await queryRunner.createForeignKey(
'data_source_group_permissions',
new TableForeignKey({
columnNames: ['data_source_id'],
referencedColumnNames: ['id'],
referencedTableName: 'data_sources',
onDelete: 'CASCADE',
})
);
await queryRunner.createForeignKey(
'data_source_group_permissions',
new TableForeignKey({
columnNames: ['group_permission_id'],
referencedColumnNames: ['id'],
referencedTableName: 'group_permissions',
onDelete: 'CASCADE',
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
if (getTooljetEdition() === TOOLJET_EDITIONS.CE) {
return;
}
await queryRunner.dropTable('data_source_group_permissions');
}
}