export_record.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. import uuid
  2. from datetime import datetime
  3. from sqlalchemy import BigInteger, DateTime, String, func
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from app.core.database import Base
  6. class ExportRecord(Base):
  7. __tablename__ = "export_records"
  8. id: Mapped[str] = mapped_column(
  9. String(64),
  10. primary_key=True,
  11. default=lambda: f"rec-{uuid.uuid4().hex[:12]}",
  12. )
  13. user_id: Mapped[str] = mapped_column(String(128), nullable=False, index=True)
  14. file_name: Mapped[str] = mapped_column(String(512), nullable=False)
  15. file_path: Mapped[str] = mapped_column(String(1024), nullable=False)
  16. file_size: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
  17. download_url: Mapped[str] = mapped_column(String(1024), nullable=False)
  18. document_id: Mapped[str | None] = mapped_column(String(64), nullable=True)
  19. style_id: Mapped[str] = mapped_column(String(64), nullable=False, default="default")
  20. created_at: Mapped[datetime] = mapped_column(
  21. DateTime(timezone=True), server_default=func.now(), nullable=False
  22. )