from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column

from advanced_alchemy.base import BigIntAuditBase


class KosyncDevice(BigIntAuditBase):
    __tablename__ = "devices"

    user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
    api_key: Mapped[str] = mapped_column(unique=True)
    name: Mapped[str]

    def __repr__(self) -> str:
        return f"KosyncDevice({self.name!r})"
