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

@Entity('job_promotions')
@Index('idx_job', ['job_post_id'])
@Index('idx_user', ['user_id'])
@Index('idx_boost', ['boost_level'])
@Index('idx_status', ['status'])
@Index('idx_time', ['starts_at', 'ends_at'])
export class JobPromotion {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Column({ type: 'int' })
  job_post_id: number;

  @Column({ type: 'int' })
  user_id: number;

  @Column({ type: 'int' })
  boost_level: number;

  @Column({ type: 'datetime' })
  starts_at: Date;

  @Column({ type: 'datetime' })
  ends_at: Date;

  @Column({
    type: 'enum',
    enum: ['active', 'expired', 'cancelled'],
    default: 'active',
  })
  status: 'active' | 'expired' | 'cancelled';

  @CreateDateColumn()
  created_at: Date;
}
