forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch-operation.entity.ts
More file actions
75 lines (60 loc) · 1.52 KB
/
Copy pathbatch-operation.entity.ts
File metadata and controls
75 lines (60 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
CreateDateColumn,
UpdateDateColumn,
Index,
} from "typeorm";
import { BatchJob } from "./batch-job.entity";
export enum BatchOperationStatus {
PENDING = "pending",
PROCESSING = "processing",
COMPLETED = "completed",
FAILED = "failed",
RETRYING = "retrying",
CANCELLED = "cancelled",
}
@Entity("batch_operations")
@Index(["batch_id"])
@Index(["status"])
@Index(["operation_index"])
export class BatchOperation {
@PrimaryGeneratedColumn("uuid")
id!: string;
@Column({ type: "uuid" })
batch_id!: string;
@Column({ type: "int" })
operation_index!: number;
@Column({
type: "enum",
enum: BatchOperationStatus,
default: BatchOperationStatus.PENDING,
})
status!: BatchOperationStatus;
@Column({ type: "jsonb" })
payload!: Record<string, any>;
@Column({ type: "jsonb", nullable: true })
result?: Record<string, any>;
@Column({ type: "text", nullable: true })
error_message?: string;
@Column({ type: "varchar", length: 50, nullable: true })
error_code?: string;
@Column({ type: "int", default: 0 })
retry_count!: number;
@Column({ type: "timestamp", nullable: true })
started_at?: Date;
@Column({ type: "timestamp", nullable: true })
completed_at?: Date;
@CreateDateColumn()
created_at!: Date;
@UpdateDateColumn()
updated_at!: Date;
@ManyToOne(() => BatchJob, (batch) => batch.operations, {
onDelete: "CASCADE",
})
@JoinColumn({ name: "batch_id" })
batch?: BatchJob;
}