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

@Entity('character_tattoos')
export class CharacterTattooEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() character_id: number;
    @Column({ type: 'varchar', length: 32 }) character_name: string;
    @Column() tattoo_id: number;
    @Column() opacity: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) modified: Date;

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

    @ManyToOne(() => TattooEntity, (tattoo) => tattoo.characterTattoos)
    @JoinColumn({
        name: 'tattoo_id',
    })
    tattoo: TattooEntity;
}
