0-30-set-custom-object-is-soft-deletable.command (#7045)

This command was supposed to set all custom objects as softDeletable.
After some discussion we realised this bool was not used as intended so
we are removing it all together until we find a better usage (remote
objects for example). This PR removes the command which won't be needed
anymore
This commit is contained in:
Weiko
2024-09-16 13:53:27 +02:00
committed by GitHub
parent 31dea498e9
commit bc99cfec98
3 changed files with 1 additions and 73 deletions

View File

@@ -1,60 +0,0 @@
import { InjectRepository } from '@nestjs/typeorm';
import { Command } from 'nest-commander';
import { In, Repository } from 'typeorm';
import {
ActiveWorkspacesCommandOptions,
ActiveWorkspacesCommandRunner,
} from 'src/database/commands/active-workspaces.command';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
type SetCustomObjectIsSoftDeletableCommandOptions =
ActiveWorkspacesCommandOptions;
@Command({
name: 'upgrade-0.30:set-custom-object-is-soft-deletable',
description: 'Set custom object is soft deletable',
})
export class SetCustomObjectIsSoftDeletableCommand extends ActiveWorkspacesCommandRunner {
constructor(
@InjectRepository(Workspace, 'core')
protected readonly workspaceRepository: Repository<Workspace>,
@InjectRepository(ObjectMetadataEntity, 'metadata')
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
) {
super(workspaceRepository);
}
async executeActiveWorkspacesCommand(
_passedParam: string[],
options: SetCustomObjectIsSoftDeletableCommandOptions,
workspaceIds: string[],
): Promise<void> {
const updateCriteria = {
workspaceId: In(workspaceIds),
isCustom: true,
isSoftDeletable: false,
};
if (options.dryRun) {
const objectsToUpdate = await this.objectMetadataRepository.find({
select: ['id'],
where: updateCriteria,
});
this.logger.log(
`Dry run: ${objectsToUpdate.length} objects would be updated`,
);
return;
}
const result = await this.objectMetadataRepository.update(updateCriteria, {
isSoftDeletable: true,
});
this.logger.log(`Updated ${result.affected} objects`);
}
}

View File

@@ -5,7 +5,6 @@ import { Repository } from 'typeorm';
import { ActiveWorkspacesCommandRunner } from 'src/database/commands/active-workspaces.command';
import { MigrateEmailFieldsToEmailsCommand } from 'src/database/commands/upgrade-version/0-30/0-30-migrate-email-fields-to-emails.command';
import { SetCustomObjectIsSoftDeletableCommand } from 'src/database/commands/upgrade-version/0-30/0-30-set-custom-object-is-soft-deletable.command';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { SyncWorkspaceMetadataCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command';
@@ -23,7 +22,6 @@ export class UpgradeTo0_30Command extends ActiveWorkspacesCommandRunner {
protected readonly workspaceRepository: Repository<Workspace>,
private readonly syncWorkspaceMetadataCommand: SyncWorkspaceMetadataCommand,
private readonly migrateEmailFieldsToEmails: MigrateEmailFieldsToEmailsCommand,
private readonly setCustomObjectIsSoftDeletableCommand: SetCustomObjectIsSoftDeletableCommand,
) {
super(workspaceRepository);
}
@@ -41,11 +39,6 @@ export class UpgradeTo0_30Command extends ActiveWorkspacesCommandRunner {
},
workspaceIds,
);
await this.setCustomObjectIsSoftDeletableCommand.executeActiveWorkspacesCommand(
passedParam,
options,
workspaceIds,
);
await this.migrateEmailFieldsToEmails.executeActiveWorkspacesCommand(
passedParam,
options,

View File

@@ -2,7 +2,6 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MigrateEmailFieldsToEmailsCommand } from 'src/database/commands/upgrade-version/0-30/0-30-migrate-email-fields-to-emails.command';
import { SetCustomObjectIsSoftDeletableCommand } from 'src/database/commands/upgrade-version/0-30/0-30-set-custom-object-is-soft-deletable.command';
import { UpgradeTo0_30Command } from 'src/database/commands/upgrade-version/0-30/0-30-upgrade-version.command';
import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@@ -28,10 +27,6 @@ import { ViewModule } from 'src/modules/view/view.module';
TypeORMModule,
ViewModule,
],
providers: [
UpgradeTo0_30Command,
MigrateEmailFieldsToEmailsCommand,
SetCustomObjectIsSoftDeletableCommand,
],
providers: [UpgradeTo0_30Command, MigrateEmailFieldsToEmailsCommand],
})
export class UpgradeTo0_30CommandModule {}