feat: Add workflow history repository files (no-changelog) (#7071)

This commit is contained in:
Omar Ajoue 2023-09-06 12:23:40 +02:00 committed by GitHub
parent 689a77cc87
commit 25dc4d7825
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 0 deletions

View file

@ -166,6 +166,9 @@ export async function init(testConnectionOptions?: ConnectionOptions): Promise<v
connectionState.connected = true;
/**
* @important Do not add to these collections. Inject the repository as a dependency instead.
*/
collections.AuthIdentity = Container.get(AuthIdentityRepository);
collections.AuthProviderSyncHistory = Container.get(AuthProviderSyncHistoryRepository);
collections.EventDestinations = Container.get(EventDestinationsRepository);

View file

@ -86,6 +86,10 @@ export interface ICredentialsOverwrite {
[key: string]: ICredentialDataDecryptedObject;
}
/**
* @important Do not add to these collections. Inject the repository as a dependency instead.
*/
/* eslint-disable @typescript-eslint/naming-convention */
export interface IDatabaseCollections extends Record<string, Repository<any>> {
AuthIdentity: AuthIdentityRepository;

View file

@ -0,0 +1,28 @@
import { Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm';
import { jsonColumnType } from './AbstractEntity';
import { IConnections } from 'n8n-workflow';
import type { INode } from 'n8n-workflow';
import { WorkflowEntity } from './WorkflowEntity';
@Entity()
export class WorkflowHistory {
@PrimaryColumn()
versionId: string;
@Column()
workflowId: string;
@Column(jsonColumnType)
nodes: INode[];
@Column(jsonColumnType)
connections: IConnections;
@Column()
authors: string;
@ManyToOne('WorkflowEntity', {
onDelete: 'CASCADE',
})
workflow: WorkflowEntity;
}

View file

@ -19,6 +19,7 @@ import { WorkflowTagMapping } from './WorkflowTagMapping';
import { WorkflowStatistics } from './WorkflowStatistics';
import { ExecutionMetadata } from './ExecutionMetadata';
import { ExecutionData } from './ExecutionData';
import { WorkflowHistory } from './WorkflowHistory';
export const entities = {
AuthIdentity,
@ -41,4 +42,5 @@ export const entities = {
WorkflowStatistics,
ExecutionMetadata,
ExecutionData,
WorkflowHistory,
};

View file

@ -15,6 +15,7 @@ export { TagRepository } from './tag.repository';
export { UserRepository } from './user.repository';
export { VariablesRepository } from './variables.repository';
export { WebhookRepository } from './webhook.repository';
export { WorkflowHistoryRepository } from './workflowHistory.repository';
export { WorkflowRepository } from './workflow.repository';
export { WorkflowStatisticsRepository } from './workflowStatistics.repository';
export { WorkflowTagMappingRepository } from './workflowTagMapping.repository';

View file

@ -0,0 +1,10 @@
import { Service } from 'typedi';
import { DataSource, Repository } from 'typeorm';
import { WorkflowHistory } from '../entities/WorkflowHistory';
@Service()
export class WorkflowHistoryRepository extends Repository<WorkflowHistory> {
constructor(dataSource: DataSource) {
super(WorkflowHistory, dataSource.manager);
}
}

View file

@ -0,0 +1,7 @@
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
import { Service } from 'typedi';
@Service()
export class WorkflowHistoryService {
constructor(private readonly workflowHistoryRepository: WorkflowHistoryRepository) {}
}