"""Sync log model for equipment import tracking."""
from sqlalchemy import Column, Integer, String, Text, TIMESTAMP, func, Index
from app.database import Base


class SyncLog(Base):
    __tablename__ = "sync_log"

    id = Column(Integer, primary_key=True, autoincrement=True)
    sync_type = Column(String(32), nullable=False, default="equipment")
    status = Column(String(32), nullable=False)
    items_processed = Column(Integer, default=0)
    items_failed = Column(Integer, default=0)
    error_message = Column(Text)
    started_at = Column(TIMESTAMP, server_default=func.now())
    completed_at = Column(TIMESTAMP)

    __table_args__ = (Index("idx_sync_log_started", "started_at"),)
