Remove typeorm service (#14116)
## Context To simplify the way we inject our default datasource, I've recently removed the token injection that was confusion since we only had once configured on the module level. Now I'm removing TypeORM service which allows us to instantiate a new Datasource with the same parameters as the default one, it was redundant and confusing.
This commit is contained in:
+6
-9
@@ -1,9 +1,9 @@
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import Dagre from '@dagrejs/dagre';
|
||||
import { Command, Option } from 'nest-commander';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { Repository } from 'typeorm';
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import {
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
|
||||
import { getWorkspaceSchemaName } from 'src/engine/workspace-datasource/utils/get-workspace-schema-name.util';
|
||||
import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service';
|
||||
import { type WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
|
||||
import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
import { type WorkflowTrigger } from 'src/modules/workflow/workflow-trigger/types/workflow-trigger.type';
|
||||
@@ -46,7 +45,8 @@ export class AddPositionsToWorkflowVersionsAndWorkflowRuns extends ActiveOrSuspe
|
||||
constructor(
|
||||
@InjectRepository(Workspace)
|
||||
protected readonly workspaceRepository: Repository<Workspace>,
|
||||
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
|
||||
@InjectDataSource()
|
||||
private readonly coreDataSource: DataSource,
|
||||
protected readonly twentyORMGlobalManager: TwentyORMGlobalManager,
|
||||
) {
|
||||
super(workspaceRepository, twentyORMGlobalManager);
|
||||
@@ -142,12 +142,9 @@ export class AddPositionsToWorkflowVersionsAndWorkflowRuns extends ActiveOrSuspe
|
||||
}: {
|
||||
workspaceId: string;
|
||||
}) {
|
||||
const mainDataSource =
|
||||
await this.workspaceDataSourceService.connectToMainDataSource();
|
||||
|
||||
const schemaName = getWorkspaceSchemaName(workspaceId);
|
||||
|
||||
const workflowRuns = await mainDataSource.query(
|
||||
const workflowRuns = await this.coreDataSource.query(
|
||||
`SELECT id, state FROM ${schemaName}."workflowRun"`,
|
||||
);
|
||||
|
||||
@@ -168,7 +165,7 @@ export class AddPositionsToWorkflowVersionsAndWorkflowRuns extends ActiveOrSuspe
|
||||
},
|
||||
};
|
||||
|
||||
await mainDataSource.query(
|
||||
await this.coreDataSource.query(
|
||||
`UPDATE ${schemaName}."workflowRun" SET state = $1::jsonb WHERE id = $2`,
|
||||
[updatedState, workflowRun.id],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user