ff-admin-server/src/entity/unit/inspection/inspection.ts

52 lines
1.4 KiB
TypeScript

import { Column, ColumnType, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { inspectionPlan } from "./inspectionPlan";
import { inspectionVersionedPlan } from "./inspectionVersionedPlan";
import { getTypeByORM } from "../../../migrations/ormHelper";
import { vehicle } from "../vehicle/vehicle";
import { equipment } from "../equipment/equipment";
@Entity()
export class inspection {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ type: "text" })
context: string;
@CreateDateColumn()
createdAt: Date;
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
finishedAt?: Date;
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
nextInspection?: Date;
@ManyToOne(() => inspectionPlan, {
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
inspectionPlan: inspectionPlan;
@ManyToOne(() => inspectionVersionedPlan, {
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
inspectionVersionedPlan: inspectionVersionedPlan;
@ManyToOne(() => equipment, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
equipment: equipment;
@ManyToOne(() => vehicle, {
nullable: true,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
vehicle: vehicle;
}