"""Report model."""

import uuid
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Enum
from sqlalchemy.dialects.postgresql import UUID, JSONB
from sqlalchemy.orm import relationship

from src.models.base import Base, TimestampMixin


class Report(Base, TimestampMixin):
    """Generated report tracking model."""

    __tablename__ = "reports"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    scenario_id = Column(
        UUID(as_uuid=True),
        ForeignKey("scenarios.id", ondelete="CASCADE"),
        nullable=False,
    )
    format = Column(Enum("pdf", "csv", name="report_format"), nullable=False)
    file_path = Column(String(500), nullable=False)
    file_size_bytes = Column(Integer, nullable=True)
    generated_by = Column(String(100), nullable=True)
    extra_data = Column(JSONB, default=dict)

    # Relationships
    scenario = relationship("Scenario", back_populates="reports")
