import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Fornecedor } from './fornecedor.entity';

@Entity('certidoes')
export class Certidao {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  fornecedor_id: string;

  @ManyToOne(() => Fornecedor, f => f.certidoes)
  @JoinColumn({ name: 'fornecedor_id' })
  fornecedor: Fornecedor;

  @Column({ length: 100 })
  tipo: string;

  @Column({ length: 100, nullable: true })
  numero: string;

  @Column()
  data_emissao: string;

  @Column()
  data_validade: string;

  @Column({ type: 'text', nullable: true })
  arquivo_url: string;

  @Column({ length: 20, default: 'vigente' })
  status: string;

  @CreateDateColumn()
  created_at: Date;
}
