2025-02-25 06:52:50 +00:00
|
|
|
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
|
|
|
|
|
|
|
|
|
|
export class AddDataSourceCreateAndDataSourceDeleteToGroupPermission1680160847536 implements MigrationInterface {
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
2025-04-07 15:17:03 +00:00
|
|
|
const tableExists = await queryRunner.hasTable('group_permissions');
|
|
|
|
|
|
|
|
|
|
if (!tableExists) {
|
|
|
|
|
console.log('Table group_permissions does not exist. Migration will not be applied.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-02-25 06:52:50 +00:00
|
|
|
await queryRunner.addColumn(
|
|
|
|
|
'group_permissions',
|
|
|
|
|
new TableColumn({
|
|
|
|
|
name: 'data_source_create',
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
default: false,
|
|
|
|
|
isNullable: false,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await queryRunner.addColumn(
|
|
|
|
|
'group_permissions',
|
|
|
|
|
new TableColumn({
|
|
|
|
|
name: 'data_source_delete',
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
default: false,
|
|
|
|
|
isNullable: false,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
2025-04-07 15:17:03 +00:00
|
|
|
const tableExists = await queryRunner.hasTable('group_permissions');
|
|
|
|
|
|
|
|
|
|
if (!tableExists) {
|
|
|
|
|
console.log('Table group_permissions does not exist. Migration will not be applied.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-02-25 06:52:50 +00:00
|
|
|
await queryRunner.dropColumn('group_permissions', 'data_source_create');
|
|
|
|
|
await queryRunner.dropColumn('group_permissions', 'data_source_delete');
|
|
|
|
|
}
|
|
|
|
|
}
|