import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';
import { CompanyEntity } from './company.entity';
import { GovernmentContractEntity } from './government-contract.entity';

@Entity('company_contracts')
export class CompanyContractEntity {
    @PrimaryGeneratedColumn() id: number;

    @Index()
    @Column()
    company_id: number;

    @Index()
    @Column()
    contract_id: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) signed: Date;
    @Column({ type: 'datetime', nullable: true, default: null }) expiration: Date | null;

    @ManyToOne(() => CompanyEntity)
    @JoinColumn({ name: 'company_id' })
    company?: CompanyEntity;

    @ManyToOne(() => GovernmentContractEntity)
    @JoinColumn({ name: 'contract_id' })
    contract?: GovernmentContractEntity;
}
