28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
|
|
"""SyncLog SQLAlchemy model."""
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from sqlalchemy import DateTime, Index, Integer, String, Text, func
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from app.database import Base
|
||
|
|
|
||
|
|
|
||
|
|
class SyncLog(Base):
|
||
|
|
"""Log entry for equipment sync operations."""
|
||
|
|
|
||
|
|
__tablename__ = "sync_log"
|
||
|
|
|
||
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||
|
|
sync_type: Mapped[str] = mapped_column(String(32), default="equipment", nullable=False)
|
||
|
|
status: Mapped[str] = mapped_column(String(32), nullable=False)
|
||
|
|
items_processed: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||
|
|
items_failed: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||
|
|
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||
|
|
started_at: Mapped[datetime] = mapped_column(server_default=func.now(), nullable=False)
|
||
|
|
completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||
|
|
|
||
|
|
__table_args__ = (
|
||
|
|
Index("idx_sync_log_started", "started_at"),
|
||
|
|
)
|