# Copyright (c) 2026 CrewHub. All rights reserved. # Proprietary and confidential. See LICENSE for details. import uuid from datetime import datetime from sqlalchemy import DateTime, Float, Index, JSON, String, Uuid, func from sqlalchemy.orm import Mapped, mapped_column from src.database import Base class InfrastructureMetric(Base): __tablename__ = "infrastructure_metrics" id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, default=uuid.uuid4) collected_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), server_default=func.now(), nullable=False ) metric_name: Mapped[str] = mapped_column(String(64), nullable=False) metric_value: Mapped[float] = mapped_column(Float, nullable=False) metric_limit: Mapped[float | None] = mapped_column(Float, nullable=True) metadata_json: Mapped[dict | None] = mapped_column(JSON, nullable=True) __table_args__ = ( Index("ix_infra_metrics_name_collected", "metric_name", "collected_at"), ) def __repr__(self) -> str: return f""