fix(core): Fix workflow activation with history and workflow history for EE (no-changelog) (#7508)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Val
2023-10-25 11:07:11 +01:00
committed by GitHub
parent 671c95760b
commit 93cfabbeac
8 changed files with 361 additions and 34 deletions

View File

@@ -6,6 +6,7 @@ import { SharedWorkflowRepository } from '@/databases/repositories';
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
import { Service } from 'typedi';
import { isWorkflowHistoryEnabled } from './workflowHistoryHelper.ee';
import { getLogger } from '@/Logger';
export class SharedWorkflowNotFoundError extends Error {}
export class HistoryVersionNotFoundError extends Error {}
@@ -66,13 +67,20 @@ export class WorkflowHistoryService {
async saveVersion(user: User, workflow: WorkflowEntity, workflowId: string) {
if (isWorkflowHistoryEnabled()) {
await this.workflowHistoryRepository.insert({
authors: user.firstName + ' ' + user.lastName,
connections: workflow.connections,
nodes: workflow.nodes,
versionId: workflow.versionId,
workflowId,
});
try {
await this.workflowHistoryRepository.insert({
authors: user.firstName + ' ' + user.lastName,
connections: workflow.connections,
nodes: workflow.nodes,
versionId: workflow.versionId,
workflowId,
});
} catch (e) {
getLogger().error(
`Failed to save workflow history version for workflow ${workflowId}`,
e as Error,
);
}
}
}
}