import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Index } from 'typeorm';
import { License } from './license.entity';

@Entity('alert_config')
@Index(['license_id'], { unique: true })
export class AlertConfig {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid' })
  license_id: string;

  @Column({ type: 'boolean', default: true })
  population_drop_enabled: boolean;

  @Column({ type: 'integer', default: 30 })
  population_drop_threshold_percent: number;

  @Column({ type: 'boolean', default: true })
  fps_degradation_enabled: boolean;

  @Column({ type: 'integer', default: 30 })
  fps_threshold: number;

  @Column({ type: 'boolean', default: true })
  notify_discord: boolean;

  @Column({ type: 'boolean', default: false })
  notify_pushbullet: boolean;

  @Column({ type: 'boolean', default: false })
  notify_email: boolean;

  @Column({ type: 'timestamptz', default: () => 'NOW()' })
  created_at: Date;

  @Column({ type: 'timestamptz', default: () => 'NOW()' })
  updated_at: Date;

  @ManyToOne(() => License, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'license_id' })
  license: License;
}
