"""
Report Model
"""
import uuid
from sqlalchemy import Column, String, DateTime, func
from sqlalchemy.dialects.postgresql import UUID as pgUUID
from sqlalchemy.orm import relationship
from .base import Base

class Report(Base):
    __tablename__ = 'reports'

    id = Column(pgUUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    symbol = Column(String, nullable=False, index=True)
    market = Column(String, nullable=False, index=True)
    status = Column(String, nullable=False, default='generating', index=True)
    created_at = Column(DateTime, server_default=func.now())
    updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())

    analysis_modules = relationship("AnalysisModule", back_populates="report", cascade="all, delete-orphan")
    progress_tracking = relationship("ProgressTracking", back_populates="report", cascade="all, delete-orphan")
