from datetime import datetime
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, JSON
from sqlalchemy.orm import relationship
from app.core.database import Base


class RiskAssessment(Base):
    __tablename__ = "risk_assessment"

    id = Column(Integer, primary_key=True, index=True)
    entity_type = Column(String(20), nullable=False)  # project, source, table, field
    entity_id = Column(Integer, nullable=False)
    entity_name = Column(String(200))
    risk_score = Column(Float, default=0.0)  # 0-100
    sensitivity_score = Column(Float, default=0.0)
    exposure_score = Column(Float, default=0.0)
    protection_score = Column(Float, default=0.0)
    details = Column(JSON, default=dict)
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
