from __future__ import annotations

from datetime import datetime

from sqlalchemy import BigInteger, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column

from supply_infra.db.base import Base


class OssLog(Base):
    """Agent 运行日志在 OSS 上的记录。"""

    __tablename__ = "oss_logs"

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
    log_name: Mapped[str | None] = mapped_column(String(256), nullable=True, comment="日志名称")
    # DDL 示例里误标为 int；按业务存 agent 名称字符串
    agent_name: Mapped[str | None] = mapped_column(String(256), nullable=True, comment="agent名称")
    oss_path: Mapped[str | None] = mapped_column(String(512), nullable=True, comment="oss路径")
    is_delete: Mapped[int] = mapped_column(
        Integer, default=0, nullable=False, comment="是否删除 0-正常 1-删除"
    )
    create_time: Mapped[datetime] = mapped_column(
        nullable=False,
        server_default=func.now(),
        comment="创建时间",
    )
    update_time: Mapped[datetime] = mapped_column(
        nullable=False,
        server_default=func.now(),
        onupdate=func.now(),
        comment="更新时间",
    )
