fennec-be/src/pipeline-tasks/pipeline-task.entity.ts
2021-03-12 23:00:12 +08:00

35 lines
983 B
TypeScript

import { AppBaseEntity } from './../commons/entities/app-base-entity';
import { Field, ObjectType } from '@nestjs/graphql';
import { Column, Entity, ManyToOne } from 'typeorm';
import { Pipeline } from '../pipelines/pipeline.entity';
import { PipelineTaskLogs } from './models/pipeline-task-logs.model';
import { TaskStatuses } from './enums/task-statuses.enum';
import { PipelineUnits } from './enums/pipeline-units.enum';
@ObjectType()
@Entity()
export class PipelineTask extends AppBaseEntity {
@ManyToOne(() => Pipeline)
pipeline: Pipeline;
@Column()
pipelineId: string;
@Column()
commit: string;
@Column({ type: 'enum', enum: PipelineUnits, array: true })
units: PipelineUnits[];
@Column({ type: 'jsonb', default: '[]' })
logs: PipelineTaskLogs[];
@Column({ type: 'enum', enum: TaskStatuses, default: TaskStatuses.pending })
status: TaskStatuses;
@Column({ nullable: true })
startedAt?: Date;
@Column({ nullable: true })
endedAt?: Date;
}