31 lines
802 B
TypeScript
31 lines
802 B
TypeScript
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, Unique } from "typeorm";
|
|
import { inspectionPlan } from "./inspectionPlan";
|
|
import { inspectionPoint } from "./inspectionPoint";
|
|
|
|
@Entity()
|
|
@Unique("unique_version", ["version", "inspectionPlanId"])
|
|
export class inspectionVersionedPlan {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id: string;
|
|
|
|
@Column({ type: "int", default: 0 })
|
|
version: number;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@Column()
|
|
inspectionPlanId: string;
|
|
|
|
@ManyToOne(() => inspectionPlan, {
|
|
nullable: false,
|
|
onDelete: "CASCADE",
|
|
onUpdate: "RESTRICT",
|
|
})
|
|
inspectionPlan: inspectionPlan;
|
|
|
|
@OneToMany(() => inspectionPoint, (ip) => ip.versionedPlan, {
|
|
cascade: ["insert"],
|
|
})
|
|
inspectionPoints: inspectionPoint[];
|
|
}
|