forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmilestone.entity.ts
More file actions
78 lines (61 loc) · 1.82 KB
/
Copy pathmilestone.entity.ts
File metadata and controls
78 lines (61 loc) · 1.82 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
76
77
78
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Repository } from './repository.entity';
import { User } from './user.entity';
import { Issue } from './issue.entity';
import { Escrow } from './escrow.entity';
import { AssetType, MilestoneStatus } from '../enums';
@Entity('milestones')
export class Milestone {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToOne(() => Repository, { onDelete: 'CASCADE' })
@JoinColumn()
repository: Repository;
@Column()
repositoryId: string;
@Column()
title: string;
@Column({ type: 'text', nullable: true })
description: string | null;
@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
@JoinColumn()
sponsor: User | null;
@Column({ type: 'varchar', nullable: true })
sponsorId: string | null;
@Column({ type: 'decimal', precision: 20, scale: 7 })
budget: string;
/** Running total already distributed to resolved issues in this milestone. */
@Column({ type: 'decimal', precision: 20, scale: 7, default: 0 })
distributed: string;
@Column({ type: 'enum', enum: AssetType, default: AssetType.USDC })
asset: AssetType;
@Column({
type: 'enum',
enum: MilestoneStatus,
default: MilestoneStatus.OPEN,
})
status: MilestoneStatus;
@Column({ type: 'timestamptz', nullable: true })
deadline: Date | null;
@OneToOne(() => Escrow, (escrow) => escrow.milestone, { nullable: true })
escrow: Escrow | null;
/** Denormalized copy of escrow.id, set whenever `escrow` is assigned. */
@Column({ type: 'varchar', nullable: true })
escrowId: string | null;
@OneToMany(() => Issue, (issue) => issue.milestone)
issues: Issue[];
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}