mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Use string ids on Credentials, Workflows, Tags, and Executions DB entities (#5041)
This commit is contained in:
committed by
GitHub
parent
8bee04cd2a
commit
ee28213538
@@ -42,7 +42,6 @@ import {
|
||||
IActivationError,
|
||||
IQueuedWorkflowActivations,
|
||||
IResponseCallbackData,
|
||||
IWebhookDb,
|
||||
IWorkflowDb,
|
||||
IWorkflowExecutionDataProcess,
|
||||
} from '@/Interfaces';
|
||||
@@ -53,7 +52,8 @@ import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData'
|
||||
|
||||
import config from '@/config';
|
||||
import { User } from '@db/entities/User';
|
||||
import { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import type { WebhookEntity } from '@db/entities/WebhookEntity';
|
||||
import * as ActiveExecutions from '@/ActiveExecutions';
|
||||
import { createErrorExecution } from '@/GenericHelpers';
|
||||
import { WORKFLOW_REACTIVATE_INITIAL_TIMEOUT, WORKFLOW_REACTIVATE_MAX_TIMEOUT } from '@/constants';
|
||||
@@ -114,7 +114,7 @@ export class ActiveWorkflowRunner {
|
||||
workflowId: workflowData.id,
|
||||
});
|
||||
try {
|
||||
await this.add(workflowData.id.toString(), 'init', workflowData);
|
||||
await this.add(workflowData.id, 'init', workflowData);
|
||||
Logger.verbose(`Successfully started workflow "${workflowData.name}"`, {
|
||||
workflowName: workflowData.name,
|
||||
workflowId: workflowData.id,
|
||||
@@ -165,10 +165,7 @@ export class ActiveWorkflowRunner {
|
||||
}
|
||||
|
||||
const activeWorkflows = await this.getActiveWorkflows();
|
||||
activeWorkflowIds = [
|
||||
...activeWorkflowIds,
|
||||
...activeWorkflows.map((workflow) => workflow.id.toString()),
|
||||
];
|
||||
activeWorkflowIds = [...activeWorkflowIds, ...activeWorkflows.map((workflow) => workflow.id)];
|
||||
|
||||
// Make sure IDs are unique
|
||||
activeWorkflowIds = Array.from(new Set(activeWorkflowIds));
|
||||
@@ -206,10 +203,10 @@ export class ActiveWorkflowRunner {
|
||||
path = path.slice(0, -1);
|
||||
}
|
||||
|
||||
let webhook = (await Db.collections.Webhook.findOne({
|
||||
let webhook = await Db.collections.Webhook.findOne({
|
||||
webhookPath: path,
|
||||
method: httpMethod,
|
||||
})) as IWebhookDb;
|
||||
});
|
||||
let webhookId: string | undefined;
|
||||
|
||||
// check if path is dynamic
|
||||
@@ -280,7 +277,7 @@ export class ActiveWorkflowRunner {
|
||||
|
||||
const nodeTypes = NodeTypes();
|
||||
const workflow = new Workflow({
|
||||
id: webhook.workflowId.toString(),
|
||||
id: webhook.workflowId,
|
||||
name: workflowData.name,
|
||||
nodes: workflowData.nodes,
|
||||
connections: workflowData.connections,
|
||||
@@ -419,12 +416,12 @@ export class ActiveWorkflowRunner {
|
||||
|
||||
path = webhookData.path;
|
||||
|
||||
const webhook = {
|
||||
const webhook: WebhookEntity = {
|
||||
workflowId: webhookData.workflowId,
|
||||
webhookPath: path,
|
||||
node: node.name,
|
||||
method: webhookData.httpMethod,
|
||||
} as IWebhookDb;
|
||||
};
|
||||
|
||||
if (webhook.webhookPath.startsWith('/')) {
|
||||
webhook.webhookPath = webhook.webhookPath.slice(1);
|
||||
@@ -549,11 +546,9 @@ export class ActiveWorkflowRunner {
|
||||
|
||||
await WorkflowHelpers.saveStaticData(workflow);
|
||||
|
||||
const webhook = {
|
||||
await Db.collections.Webhook.delete({
|
||||
workflowId: workflowData.id,
|
||||
} as IWebhookDb;
|
||||
|
||||
await Db.collections.Webhook.delete(webhook);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,15 +708,15 @@ export class ActiveWorkflowRunner {
|
||||
`The trigger node "${node.name}" of workflow "${workflowData.name}" failed with the error: "${error.message}". Will try to reactivate.`,
|
||||
{
|
||||
nodeName: node.name,
|
||||
workflowId: workflowData.id.toString(),
|
||||
workflowId: workflowData.id,
|
||||
workflowName: workflowData.name,
|
||||
},
|
||||
);
|
||||
|
||||
// Remove the workflow as "active"
|
||||
|
||||
await this.activeWorkflows?.remove(workflowData.id.toString());
|
||||
this.activationErrors[workflowData.id.toString()] = {
|
||||
await this.activeWorkflows?.remove(workflowData.id);
|
||||
this.activationErrors[workflowData.id] = {
|
||||
time: new Date().getTime(),
|
||||
error: {
|
||||
message: error.message,
|
||||
@@ -897,7 +892,7 @@ export class ActiveWorkflowRunner {
|
||||
activationMode: WorkflowActivateMode,
|
||||
workflowData: IWorkflowDb,
|
||||
): void {
|
||||
const workflowId = workflowData.id.toString();
|
||||
const workflowId = workflowData.id;
|
||||
const workflowName = workflowData.name;
|
||||
|
||||
const retryFunction = async () => {
|
||||
|
||||
Reference in New Issue
Block a user