"""Daily Report photo metadata. Photo files live in the managed application storage, never in SQLite. This table keeps metadata and the link to the owning Daily Report. Binary content is not stored here. Photos are attached to the Daily Report as a whole (REQ), not to individual work positions. """ from sqlalchemy import ( Column, DateTime, ForeignKey, Integer, String, ) from sqlalchemy.orm import relationship from sqlalchemy.sql import func from app.database.database import Base class DailyReportPhoto(Base): __tablename__ = "daily_report_photos" id = Column(Integer, primary_key=True, index=True) project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True) daily_report_id = Column( Integer, ForeignKey("daily_reports.id"), nullable=False, index=True ) # Relative path under DOCUMENT_STORAGE_ROOT. Never an absolute path or URL. storage_key = Column(String, nullable=False) # Display-only label from the uploader. Never used to build a path. original_name = Column(String, nullable=True) content_type = Column(String(100), nullable=False) file_size = Column(Integer, nullable=False) content_hash = Column(String(64), nullable=False) sort_order = Column(Integer, nullable=False, default=0, server_default="0") created_at = Column(DateTime, nullable=False, server_default=func.now()) report = relationship("DailyReport", back_populates="photos") def __repr__(self): return ( f"" )