import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { VehicleUpgradeEntity } from './vehicle-upgrade.entity';
import { VehicleEntity } from './vehicle.entity';

@Entity('vehicle_vehicle_upgrades')
export class VehicleVehicleUpgradeEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) vehicle_id: number;
    @Column({ type: 'int' }) vehicle_upgrade_id: number;

    @ManyToOne(() => VehicleEntity, (vehicle) => vehicle.upgrades)
    @JoinColumn({ name: 'vehicle_id' })
    vehicle: VehicleEntity;

    @OneToOne(() => VehicleUpgradeEntity)
    @JoinColumn({
        name: 'vehicle_upgrade_id',
        referencedColumnName: 'id',
    })
    upgrade: VehicleUpgradeEntity;
}
