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

@Entity('health_check_results')
export class HealthCheckResult {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

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

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

  @Column({ type: 'varchar', length: 255, nullable: true })
  serverHost?: string;

  @Column({ type: 'varchar', length: 20 })
  checkType!: 'ping' | 'http' | 'tcp' | 'ssh';

  @Column({ type: 'varchar', length: 20 })
  status!: 'healthy' | 'degraded' | 'down' | 'pending';

  @Column({ type: 'int', nullable: true })
  latencyMs?: number;

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

  @Column({ type: 'text', nullable: true })
  error?: string;

  @CreateDateColumn({ type: 'timestamptz' })
  createdAt!: Date;
}
