workflow_run.py 1.5 KB

12345678910111213141516171819202122232425262728
  1. from datetime import datetime
  2. from sqlalchemy import DateTime, Integer, String, Text
  3. from sqlalchemy.orm import Mapped, mapped_column
  4. from core_db import AuditMixin, Base, TenantMixin, VersionMixin
  5. class WorkflowRun(TenantMixin, AuditMixin, VersionMixin, Base):
  6. __tablename__ = "workflow_run"
  7. app_id: Mapped[str] = mapped_column(String(36), index=True)
  8. app_version_id: Mapped[str] = mapped_column(String(36))
  9. workflow_id: Mapped[str] = mapped_column(String(36))
  10. workflow_version_id: Mapped[str] = mapped_column(String(36))
  11. session_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  12. parent_run_id: Mapped[str | None] = mapped_column(String(36), nullable=True)
  13. root_run_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  14. run_type: Mapped[str] = mapped_column(String(32), default="main")
  15. status: Mapped[str] = mapped_column(String(32), default="pending", index=True)
  16. trigger_type: Mapped[str] = mapped_column(String(32), default="user")
  17. priority: Mapped[int] = mapped_column(Integer, default=0)
  18. current_node_count: Mapped[int] = mapped_column(Integer, default=0)
  19. started_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
  20. finished_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
  21. error_code: Mapped[str | None] = mapped_column(String(64), nullable=True)
  22. error_message: Mapped[str | None] = mapped_column(Text, nullable=True)