base unit data
This commit is contained in:
parent
15a511f942
commit
95d1113ff9
7 changed files with 232 additions and 0 deletions
38
src/entity/unit/vehicle/vehicle.ts
Normal file
38
src/entity/unit/vehicle/vehicle.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||||
import { VehicleType } from "./vehicleType";
|
||||
import { DamageReport } from "../damageReport";
|
||||
|
||||
@Entity()
|
||||
export class Vehicle {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, unique: true })
|
||||
code?: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
name: string;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
location: string;
|
||||
|
||||
@Column({ type: getTypeByORM("datetime").type as ColumnType })
|
||||
commissioned: Date;
|
||||
|
||||
@Column({ type: getTypeByORM("datetime").type as ColumnType, nullable: true })
|
||||
decommissioned?: Date;
|
||||
|
||||
@Column()
|
||||
vehicleTypeId: string;
|
||||
|
||||
@ManyToOne(() => VehicleType, {
|
||||
nullable: false,
|
||||
onDelete: "RESTRICT",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
vehicleType: VehicleType;
|
||||
|
||||
@OneToMany(() => DamageReport, (d) => d.vehicle, { cascade: ["insert"] })
|
||||
reports: DamageReport[];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue