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

@Entity('email_tokens')
export class EmailTokens {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', length: 64, unique: true })
  token: string;

  @Column({ type: 'varchar', length: 50 })
  token_type: string; // 'ai_interview_schedule', 'password_reset', etc.

  @Column({ type: 'int' })
  reference_id: number; // ID of the related record (e.g., schedule_id)

  @Column({ type: 'int' })
  user_id: number; // Owner of this token

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

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

  @CreateDateColumn({ type: 'timestamp' })
  created_at: Date;

  @UpdateDateColumn({ type: 'timestamp' })
  updated_at: Date;
}
