-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): Don't create multiple owners when importing credentials or workflows #9112
Changes from 8 commits
910a1aa
acb8671
4be1941
c2d4fad
a6d0eef
9872849
0aaddc0
f87da4a
e25b5f9
65c9426
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has been refactored so that reading the input files and checking them happens in only one place. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,14 +53,18 @@ export class ImportService { | |
this.logger.info(`Deactivating workflow "${workflow.name}". Remember to activate later.`); | ||
} | ||
|
||
const upsertResult = await tx.upsert(WorkflowEntity, workflow, ['id']); | ||
const exists = workflow.id ? await tx.existsBy(WorkflowEntity, { id: workflow.id }) : false; | ||
|
||
const upsertResult = await tx.upsert(WorkflowEntity, workflow, ['id']); | ||
const workflowId = upsertResult.identifiers.at(0)?.id as string; | ||
|
||
await tx.upsert(SharedWorkflow, { workflowId, userId, role: 'workflow:owner' }, [ | ||
'workflowId', | ||
'userId', | ||
]); | ||
// Create relationship if the workflow was inserted instead of updated. | ||
if (!exists) { | ||
await tx.upsert(SharedWorkflow, { workflowId, userId, role: 'workflow:owner' }, [ | ||
'workflowId', | ||
'userId', | ||
]); | ||
} | ||
Comment on lines
+62
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Part of the fix is here. This function will only create an owner if the workflow is imported for the first time. |
||
|
||
if (!workflow.tags?.length) continue; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has been refactored so that reading the input files, checking and preparing the credentials only happens in one place.