import { Column, Entity, JoinColumn, OneToMany, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';
import { VehicleEntity } from './vehicle.entity';

@Entity('vehicle_registry')
export class VehicleRegistryEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) vehicle_id: number;
    @Column({ type: 'datetime' }) first_registration: Date;
    @Column({ type: 'datetime' }) renew_registration: Date;
    @Column({ type: 'datetime', default: null }) title_change: Date | null;
    @Column({ type: 'varchar', length: 100 }) registered_owner: string;
    @Column({ type: 'varchar', length: 10, default: null }) existing_plate: string;

    @OneToOne(() => VehicleEntity)
    @JoinColumn({
        name: 'vehicle_id',
        referencedColumnName: 'id',
    })
    vehicle?: VehicleEntity;
}
