from sqlalchemy import Column, Integer, String, DateTime, Text, func
from app.database import Base


class PlanLog(Base):
    """计划操作/状态变更日志"""
    __tablename__ = "plan_logs"

    id = Column(Integer, primary_key=True, index=True)
    plan_id = Column(Integer, index=True, comment="计划id")
    plan_no = Column(String(30), index=True, comment="计划号")
    coil_no = Column(String(30), comment="冷卷号")
    action = Column(String(20), comment="操作: 新增/移动/投入生产/生产完成/删除")
    from_status = Column(String(20), comment="原状态")
    to_status = Column(String(20), comment="新状态")
    position = Column(String(40), comment="变化位置")
    operator = Column(String(50), comment="操作人")
    detail = Column(Text, comment="说明")
    created_at = Column(DateTime, server_default=func.now(), index=True)
