refactor: Upgrade typeorm to 0.3.x (#5151)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-13 18:12:22 +01:00
committed by GitHub
parent 6608e69457
commit 0a5ab560b1
85 changed files with 579 additions and 636 deletions

View File

@@ -20,8 +20,6 @@ import {
sleep,
} from 'n8n-workflow';
import { FindOneOptions, getConnectionManager } from 'typeorm';
import { CredentialsOverwrites } from '@/CredentialsOverwrites';
import { CredentialTypes } from '@/CredentialTypes';
import * as Db from '@/Db';
@@ -125,7 +123,7 @@ export class Worker extends Command {
async runJob(job: Queue.Job, nodeTypes: INodeTypes): Promise<Queue.JobResponse> {
const { executionId, loadStaticData } = job.data;
const executionDb = await Db.collections.Execution.findOne(executionId);
const executionDb = await Db.collections.Execution.findOneBy({ id: executionId });
if (!executionDb) {
LoggerProxy.error(
@@ -145,14 +143,13 @@ export class Worker extends Command {
let { staticData } = currentExecutionDb.workflowData;
if (loadStaticData) {
const findOptions = {
const workflowData = await Db.collections.Workflow.findOne({
select: ['id', 'staticData'],
} as FindOneOptions;
const workflowData = await Db.collections.Workflow.findOne(
currentExecutionDb.workflowData.id,
findOptions,
);
if (workflowData === undefined) {
where: {
id: currentExecutionDb.workflowData.id,
},
});
if (workflowData === null) {
LoggerProxy.error(
'Worker execution failed because workflow could not be found in database.',
{
@@ -384,10 +381,10 @@ export class Worker extends Command {
async (req: express.Request, res: express.Response) => {
LoggerProxy.debug('Health check started!');
const connection = getConnectionManager().get();
const connection = Db.getConnection();
try {
if (!connection.isConnected) {
if (!connection.isInitialized) {
// Connection is not active
throw new Error('No active database connection!');
}