from datetime import datetime from core_db import AuditMixin, Base, EntityMixin, VersionMixin from core_shared import JSONValue from sqlalchemy import DateTime, String, Text from sqlalchemy.dialects.sqlite import JSON from sqlalchemy.orm import Mapped, mapped_column class SkillRun(EntityMixin, AuditMixin, VersionMixin, Base): __tablename__ = "skill_run" skill_id: Mapped[str] = mapped_column(String(36), index=True) skill_version_id: Mapped[str] = mapped_column(String(36), index=True) installation_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True) status: Mapped[str] = mapped_column(String(32), default="queued", index=True) input_json: Mapped[dict[str, JSONValue]] = mapped_column(JSON, default=dict) output_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True) output_text: Mapped[str | None] = mapped_column(Text, nullable=True) worker_key: Mapped[str | None] = mapped_column(String(128), nullable=True) started_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) finished_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) error_code: Mapped[str | None] = mapped_column(String(64), nullable=True) error_message: Mapped[str | None] = mapped_column(Text, nullable=True)