import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { EmergencyCallEntity } from './emergency-call.entity';
import { CharacterEntity } from './character.entity';

@Entity('emergency_call_responses')
export class EmergencyCallResponseEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() emergency_call_id: number;
    @Column() character_id: number;
    @Column({ type: 'varchar', length: 128 }) responder_name: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: Date;

    @ManyToOne(() => EmergencyCallEntity, (call) => call.responders)
    @JoinColumn({ name: 'emergency_call_id' })
    emergency_call: EmergencyCallEntity;

    @OneToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'character_id',
        referencedColumnName: 'id',
    })
    character: CharacterEntity;
}
