Files
edr-platform/apps/edr-freight-api/src/modules/rule-engine/entities/yard-position.entity.ts
2026-08-18 12:55:11 +00:00

29 lines
992 B
TypeScript

import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
import { Yard } from './yard.entity';
/**
* One desk staffed at one yard.
*
* The pairing that yard access scoping resolves against: a caller's active
* position decides which yards they may touch. Position rows live in `iam`
* (`iam.positions` — what the user-management tree labels "departments"), so
* `positionId` is an unconstrained uuid by design; see the migration for why.
*/
@Entity({ schema: 'freight', name: 'yard_positions' })
@Index(['yardId'])
@Index(['positionId'])
export class YardPosition extends BaseEntity {
@Column({ name: 'yard_id', type: 'uuid' })
yardId!: string;
@ManyToOne(() => Yard, { nullable: false, onDelete: 'CASCADE' })
@JoinColumn({ name: 'yard_id' })
yard?: Yard;
/** `iam.positions.id`. No FK — IAM is package-owned and soft-deletes. */
@Column({ name: 'position_id', type: 'uuid' })
positionId!: string;
}