import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';

@Entity('mugshots')
export class MugshotEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 36 }) key: string;
    @Index()
    @Column()
    character_id: number;
    @Column({ type: 'varchar', length: 32 }) character_name: string;
    @Index()
    @Column()
    taken_by_character_id: number;
    @Column({ type: 'varchar', length: 64 }) taken_by: string;
    @Column({ type: 'varchar', length: 16 }) source: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: Date;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({ name: 'character_id' })
    character?: CharacterEntity;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({ name: 'taken_by_character_id' })
    takenByCharacter?: CharacterEntity;
}
