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

@Entity('alert_events')
export class AlertEvent {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({ type: 'varchar', length: 20 })
  tenantId!: string;

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

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

  @Column({ type: 'varchar', length: 20 })
  severity!: 'info' | 'warning' | 'critical' | 'fatal';

  @Column({ type: 'text' })
  message!: string;

  @Column({ type: 'double precision', nullable: true })
  metricValue?: number;

  @Column({ type: 'varchar', length: 20, default: 'firing' })
  status!: 'firing' | 'resolved' | 'acknowledged';

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

  @Column({ type: 'timestamptz', nullable: true })
  resolvedAt?: Date;

  @Column({ type: 'uuid', nullable: true })
  acknowledgedBy?: string;
}
