import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, } from 'typeorm'; import { Cluster } from './cluster.entity'; import { ClusterPool, PoolStrategy } from './cluster-pool.entity'; import { Application } from '../../applications/entities/application.entity'; export type ClusterAllocationStatus = 'success' | 'failed'; @Entity('cluster_allocation_logs') export class ClusterAllocationLog { @PrimaryGeneratedColumn('uuid') id: string; // Explicit `type` required: `string | null` reflects as Object and crashes // TypeORM at metadata build (DataTypeNotSupportedError). @Column({ type: 'uuid', nullable: true }) applicationId?: string | null; @ManyToOne(() => Application, { nullable: true, onDelete: 'SET NULL' }) @JoinColumn({ name: 'applicationId' }) application: Application; @Column() userId: string; @Column({ type: 'uuid', nullable: true }) poolId?: string | null; @ManyToOne(() => ClusterPool, { nullable: true, onDelete: 'SET NULL' }) @JoinColumn({ name: 'poolId' }) pool: ClusterPool; @Column({ type: 'uuid', nullable: true }) selectedClusterId?: string | null; @ManyToOne(() => Cluster, { nullable: true, onDelete: 'SET NULL' }) @JoinColumn({ name: 'selectedClusterId' }) selectedCluster: Cluster; @Column({ default: 'weighted-resource' }) strategy: PoolStrategy; @Column({ type: 'jsonb', nullable: true }) estimatedRequest: Record; @Column({ type: 'jsonb', nullable: true }) candidateScores: Record[]; @Column({ type: 'jsonb', nullable: true }) rejectionReasons: Record[]; @Column({ default: 'success' }) status: ClusterAllocationStatus; @Column({ nullable: true }) message: string; @CreateDateColumn() createdAt: Date; }