mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 00:05:02 +00:00
27 lines
901 B
TypeScript
27 lines
901 B
TypeScript
import { BaseEntity } from '@edr/api-common';
|
|
import { Entity, Index, JoinColumn, ManyToOne, Column } from 'typeorm';
|
|
|
|
import { Booking } from '../../bookings/entities/booking.entity';
|
|
import { TrainSchedule } from './train-schedule.entity';
|
|
|
|
@Entity({ schema: 'freight', name: 'train_schedule_bookings' })
|
|
@Index(['trainScheduleId', 'bookingId'], { unique: true })
|
|
@Index(['bookingId'], { unique: true })
|
|
export class TrainScheduleBooking extends BaseEntity {
|
|
@Column({ name: 'train_schedule_id', type: 'uuid' })
|
|
trainScheduleId!: string;
|
|
|
|
@ManyToOne(() => TrainSchedule, (trainSchedule) => trainSchedule.scheduleBookings, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'train_schedule_id' })
|
|
trainSchedule?: TrainSchedule;
|
|
|
|
@Column({ name: 'booking_id', type: 'uuid' })
|
|
bookingId!: string;
|
|
|
|
@ManyToOne(() => Booking)
|
|
@JoinColumn({ name: 'booking_id' })
|
|
booking?: Booking;
|
|
}
|