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

class AnalysisModule(Base):
    __tablename__ = 'analysis_modules'

    id = Column(pgUUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    report_id = Column(pgUUID(as_uuid=True), ForeignKey('reports.id'), nullable=False, index=True)
    module_type = Column(String, nullable=False)
    content = Column(JSON)
    status = Column(String, nullable=False, default='pending', index=True)
    error_message = Column(String)

    report = relationship("Report", back_populates="analysis_modules")
