import { Entity, Column, PrimaryGeneratedColumn, Unique, Index } from 'typeorm';

@Entity('iso_certificates')
@Unique(['year', 'month', 'country', 'companyName', 'standard'])
export class IsoCertificate {
  @PrimaryGeneratedColumn('increment')
  id: number;

  @Column()
  year: number;

  @Column({ length: 20 }) // months will never be very long
  month: string;

  @Column({ length: 100 }) // country names can be limited
  country: string;

  @Column({ length: 255 })
  @Index()
  companyName: string;

  @Column({ length: 50 }) // standard names like 9001, GMP, etc.
  @Index()
  standard: string;

  @Column({ length: 255 })
  fileName: string;

  @Column({ length: 255 })
  fileUrl: string;

  @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
  uploadDate: Date;

  @Column({ nullable: true })
  fileSize: number;
}
