from datetime import datetime, timezone from typing import Optional from sqlalchemy import BigInteger, DateTime, String from sqlalchemy.orm import Mapped, mapped_column from app.db import Base class File(Base): __tablename__ = "files" id: Mapped[str] = mapped_column(String(64), primary_key=True) tenant_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True) uploaded_by: Mapped[str] = mapped_column(String(64), nullable=False, index=True) bucket: Mapped[str] = mapped_column(String(100), nullable=False) object_key: Mapped[str] = mapped_column(String(500), nullable=False) file_name: Mapped[str] = mapped_column(String(255), nullable=False) mime_type: Mapped[str] = mapped_column(String(100), nullable=False) file_size: Mapped[int] = mapped_column(BigInteger, nullable=False) file_hash: Mapped[str] = mapped_column(String(128), nullable=False) file_type: Mapped[str] = mapped_column(String(50), nullable=False) # contract / report / knowledge_doc status: Mapped[str] = mapped_column(String(20), default="active") created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))