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

@Entity('otp_requests')
export class OtpRequests {
  @PrimaryGeneratedColumn()
  id: number;

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

  // @Column({ type: 'varchar', length: 6, nullable: true }) // 6-digit OTP (COMMENTED OUT)
  @Column({ type: 'varchar', length: 4, nullable: true }) // 4-digit OTP
  otp: string;

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

  @Column({ name: 'otp_expires_at', type: 'datetime', nullable: true })
  otp_expires_at: Date;

  @Column({
    name: 'updated_at',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updated_at: Date;
}
