Files
edr-platform/apps/edr-freight-api/src/modules/scheduling-reschedule/entities/scheduling-event.entity.ts

34 lines
1004 B
TypeScript

import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index } from 'typeorm';
export const RESCHEDULE_TRIGGERS = [
'GOVERNMENT_PREEMPT',
'TRAIN_MAINTENANCE',
'MANUAL',
'CAPACITY_REBALANCE',
] as const;
export type RescheduleTrigger = (typeof RESCHEDULE_TRIGGERS)[number];
@Entity({ schema: 'freight', name: 'scheduling_events' })
@Index(['trainScheduleId'])
export class SchedulingEvent extends BaseEntity {
@Column({ name: 'train_schedule_id', type: 'uuid' })
trainScheduleId!: string;
@Column({ name: 'trigger', type: 'varchar', length: 40 })
trigger!: RescheduleTrigger;
@Column({ name: 'actor_user_id', type: 'uuid', nullable: true })
actorUserId?: string | null;
@Column({ name: 'reason', type: 'text', nullable: true })
reason?: string | null;
@Column({ name: 'plan_snapshot', type: 'jsonb' })
planSnapshot!: Record<string, unknown>;
@Column({ name: 'displaced_booking_ids', type: 'jsonb', default: '[]' })
displacedBookingIds!: string[];
}