import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CommercialDriversLicenseTypeEntity } from './commercial-drivers-license-type.entity';

@Entity('commercial_drivers_licenses')
export class CommercialDriversLicenseEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) character_id: number | null;
    @Column({ type: 'varchar', length: 32 }) character_name: string | null;
    @Column() commercial_drivers_license_type_id: number;
    @Column({ type: 'int', default: 0 }) xp: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'datetime' }) expires: Date;

    @ManyToOne(() => CommercialDriversLicenseTypeEntity, (cdlte) => cdlte.cdls)
    @JoinColumn({ name: 'commercial_drivers_license_type_id' })
    type: CommercialDriversLicenseTypeEntity;
}
