import { Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CompanyEntity } from './company.entity';
import { CompanyPositionEntity } from './company-position.entity';

@Entity('character_company_positions')
export class CharacterCompanyPositionEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) character_id: number;
    @Column({ type: 'int' }) company_id: number;
    @Column({ type: 'int' }) company_position_id: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'int' }) created_by: number;

    @OneToOne(() => CompanyEntity)
    @JoinColumn({
        name: 'company_id',
        referencedColumnName: 'id',
    })
    company: CompanyEntity;

    @OneToOne(() => CompanyPositionEntity)
    @JoinColumn({
        name: 'company_position_id',
        referencedColumnName: 'id',
    })
    companyPosition: CompanyPositionEntity;
}
