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

@Entity('franchise_history')
export class FranchiseHistory {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Index()
  @Column('int', { name: 'franchise_id', nullable: true, default: null })
  franchiseId: number | null;

  @Index()
  @Column('int', { name: 'temp_franchise_id', nullable: true, default: null })
  tempFranchiseId: number | null;

  @Column('enum', {
    name: 'action',
    enum: ['applied', 'approved', 'rejected', 'updated'],
    nullable: false,
  })
  action: 'applied' | 'approved' | 'rejected' | 'updated';

  @Index()
  @Column('int', { name: 'performed_by', nullable: true, default: null })
  performedBy: number | null;

  @Column('text', { name: 'remarks', nullable: true, default: null })
  remarks: string | null;

  @CreateDateColumn({
    name: 'created_at',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createdAt: Date;
}
