Files
edr-platform/apps/edr-freight-api/src/modules/rule-engine/entities/yard.entity.ts
Marshal 771aa2a605 Add train deactivation feature and import train number management
- Introduced DEACTIVATED status for trains, allowing staff to park trains indefinitely.
- Implemented methods to deactivate and reactivate trains in the TrainBuilderService.
- Added UI components for train deactivation and reactivation in TrainBuilderDetailPage.
- Created a dropdown setting for admin-managed import train numbers, with corresponding migrations.
- Updated yard code length to accommodate soft-delete suffix.
- Enhanced train status handling to include DEACTIVATED state.
2026-07-20 07:04:23 +00:00

37 lines
1.3 KiB
TypeScript

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 `@<epoch-ms>` 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;
}