import { BaseEntity } from '@edr/api-common'; import { YardCountry } from '@edr/types'; import { Column, Entity, Index } from 'typeorm'; @Entity({ schema: 'freight', name: 'yards' }) @Index(['code']) @Index(['country']) @Index(['isActive']) export class Yard extends BaseEntity { // 40 leaves room for the `@` suffix soft-delete appends to free the code. @Column({ name: 'code', type: 'varchar', length: 40, unique: true }) code!: string; @Column({ name: 'label', type: 'varchar', length: 100 }) label!: string; // Constrained to YardCountry by DTO validation + a DB CHECK constraint; // route/schedule trade direction is derived from this value. Typed as the // enum's literal values so plain strings from seeds/queries still fit. @Column({ name: 'country', type: 'varchar', length: 50 }) country!: `${YardCountry}`; @Column({ name: 'is_active', type: 'boolean', default: true }) isActive!: boolean; /** * This yard has the equipment to load/unload cargo. Intercity bookings can only * be loaded at their origin and unloaded at their destination where this is * true. What the facility can do lives on the YardFacility record. */ @Column({ name: 'has_facility', type: 'boolean', default: false }) hasFacility!: boolean; @Column({ name: 'display_order', type: 'int', default: 1 }) displayOrder!: number; }