fix(core): Fix update workflow cli command being unable to activate all workflows (#8412)
Co-authored-by: Daniel Schröder <daniel.schroeder@skriptfabrik.com>
This commit is contained in:
@@ -50,16 +50,22 @@ export class UpdateWorkflowCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
const newState = flags.active === 'true';
|
||||
const action = newState ? 'Activating' : 'Deactivating';
|
||||
|
||||
if (flags.id) {
|
||||
this.logger.info(`Deactivating workflow with ID: ${flags.id}`);
|
||||
this.logger.info(`${action} workflow with ID: ${flags.id}`);
|
||||
await Container.get(WorkflowRepository).updateActiveState(flags.id, newState);
|
||||
} else {
|
||||
this.logger.info('Deactivating all workflows');
|
||||
await Container.get(WorkflowRepository).deactivateAll();
|
||||
this.logger.info(`${action} all workflows`);
|
||||
if (newState) {
|
||||
await Container.get(WorkflowRepository).activateAll();
|
||||
} else {
|
||||
await Container.get(WorkflowRepository).deactivateAll();
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.info('Done');
|
||||
this.logger.info('Activation or deactivation will not take effect if n8n is running.');
|
||||
this.logger.info('Please restart n8n for changes to take effect if n8n is currently running.');
|
||||
}
|
||||
|
||||
async catch(error: Error) {
|
||||
|
||||
@@ -213,6 +213,10 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||
return await this.update({ active: true }, { active: false });
|
||||
}
|
||||
|
||||
async activateAll() {
|
||||
return await this.update({ active: false }, { active: true });
|
||||
}
|
||||
|
||||
async findByActiveState(activeState: boolean) {
|
||||
return await this.findBy({ active: activeState });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user