import { BaseEntity } from '@edr/api-common'; import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from 'typeorm'; import { FirstMile } from './first-mile.entity'; import { Vehicle } from '../../vehicles/entities/vehicle.entity'; @Entity({ name: 'first_mile_container_allocations', schema: 'freight' }) @Index(['firstMileId']) @Index(['vehicleId']) export class FirstMileContainerAllocation extends BaseEntity { @Column({ name: 'first_mile_id', type: 'uuid' }) firstMileId!: string; @ManyToOne(() => FirstMile, (firstMile) => firstMile.containerAllocations, { nullable: false, eager: false, }) @JoinColumn({ name: 'first_mile_id' }) firstMile?: FirstMile; @Column({ name: 'container_id', type: 'uuid' }) containerId!: string; @Column({ name: 'vehicle_id', type: 'uuid', nullable: true }) vehicleId?: string | null; @ManyToOne(() => Vehicle, { nullable: true, eager: false }) @JoinColumn({ name: 'vehicle_id' }) vehicle?: Vehicle | null; @Column({ name: 'container_type', type: 'text' }) containerType!: string; @Column({ name: 'quantity', type: 'int', default: 1 }) quantity!: number; }