refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8212)

Follow-up to: https://github.com/n8n-io/n8n/pull/8186
This commit is contained in:
Iván Ovejero
2024-01-05 13:06:24 +01:00
committed by GitHub
parent bed04ec122
commit 23a4ac96c0
10 changed files with 69 additions and 47 deletions

View File

@@ -1,4 +1,3 @@
import { In } from 'typeorm';
import { User } from '@db/entities/User';
import { SharedCredentials } from '@db/entities/SharedCredentials';
import { SharedWorkflow } from '@db/entities/SharedWorkflow';
@@ -214,10 +213,11 @@ export class UsersController {
// Prevents issues with unique key constraints since user being assigned
// workflows and credentials might be a sharee
await transactionManager.delete(SharedWorkflow, {
user: transferee,
workflowId: In(sharedWorkflowIds),
});
await this.sharedWorkflowRepository.deleteByIds(
transactionManager,
sharedWorkflowIds,
transferee,
);
// Transfer ownership of owned workflows
await transactionManager.update(
@@ -239,10 +239,11 @@ export class UsersController {
// Prevents issues with unique key constraints since user being assigned
// workflows and credentials might be a sharee
await transactionManager.delete(SharedCredentials, {
user: transferee,
credentialsId: In(sharedCredentialIds),
});
await this.sharedCredentialsRepository.deleteByIds(
transactionManager,
sharedCredentialIds,
transferee,
);
// Transfer ownership of owned credentials
await transactionManager.update(