Spaces:
Sleeping
Sleeping
| """Document ORM model for uploaded source files and processing status.""" | |
| from datetime import datetime | |
| from uuid import uuid4 | |
| from sqlalchemy import DateTime, Integer, String, Text | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.database import Base | |
| class Document(Base): | |
| """ORM model representing an ingested document.""" | |
| __tablename__ = "documents" | |
| id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid4())) | |
| filename: Mapped[str] = mapped_column(String(255), nullable=False) | |
| original_filename: Mapped[str] = mapped_column(String(255), nullable=False) | |
| file_type: Mapped[str] = mapped_column(String(50), nullable=False) | |
| file_size_bytes: Mapped[int | None] = mapped_column(Integer) | |
| file_path: Mapped[str] = mapped_column(String(500), nullable=False) | |
| status: Mapped[str] = mapped_column(String(50), default="pending") | |
| total_chunks: Mapped[int] = mapped_column(Integer, default=0) | |
| error_message: Mapped[str | None] = mapped_column(Text) | |
| uploaded_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow) | |
| processed_at: Mapped[datetime | None] = mapped_column(DateTime) | |
| def __repr__(self) -> str: | |
| """Return a concise string representation for debugging.""" | |
| return f"Document(id={self.id!r}, filename={self.filename!r}, status={self.status!r})" | |