"""
Linux BenchTools - Peripheral History Models
"""

from sqlalchemy import Column, Integer, String, DateTime, Text
from sqlalchemy.sql import func
from app.db.base import BasePeripherals


class PeripheralLocationHistory(BasePeripherals):
    """
    History of peripheral movements (location changes, assignments)
    """
    __tablename__ = "peripheral_location_history"

    id = Column(Integer, primary_key=True, index=True)
    peripheral_id = Column(Integer, nullable=False, index=True)

    # Location changes
    from_location_id = Column(Integer)
    to_location_id = Column(Integer)

    # Device assignments
    from_device_id = Column(Integer)
    to_device_id = Column(Integer)

    # Action details
    action = Column(String(50), nullable=False)  # moved, assigned, unassigned, stored
    timestamp = Column(DateTime, server_default=func.now())
    notes = Column(Text)
    user = Column(String(100))

    def __repr__(self):
        return f"<PeripheralLocationHistory(id={self.id}, action='{self.action}')>"
