"""Knowledge Graph 增量同步运行日志。""" from __future__ import annotations from typing import Any, Optional from sqlalchemy import Integer, TEXT, TIMESTAMP, VARCHAR from sqlalchemy.orm import Mapped, mapped_column from .base import Base from .types import JSONB class KGSyncRun(Base): __tablename__ = "kg_sync_runs" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) run_type: Mapped[str] = mapped_column(VARCHAR(40), nullable=False, index=True) trigger_source: Mapped[str] = mapped_column(VARCHAR(40), nullable=False, default="system", index=True) status: Mapped[str] = mapped_column(VARCHAR(20), nullable=False, default="running", index=True) started_at: Mapped[Optional[TIMESTAMP]] = mapped_column(TIMESTAMP, nullable=False, index=True) ended_at: Mapped[Optional[TIMESTAMP]] = mapped_column(TIMESTAMP, nullable=True, index=True) duration_ms: Mapped[Optional[int]] = mapped_column(Integer, nullable=True) input_payload: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True) result_payload: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True) error_message: Mapped[Optional[str]] = mapped_column(TEXT, nullable=True)