


from sqlalchemy.orm import relationship
from sqlalchemy import BigInteger, Boolean, Column, DateTime, ForeignKey, String

from discord_shared_db.base import Base


class UserSession(Base):
    __tablename__ = "user_sessions"

    id = Column(BigInteger, primary_key=True)
    user_id = Column(BigInteger, ForeignKey("users.user_id"), nullable=False)

    refresh_token_hash = Column(String, nullable=False)
    created_at = Column(DateTime, nullable=False)
    expires_at = Column(DateTime, nullable=False)
    revoked = Column(Boolean, default=False)

    user = relationship("User", back_populates="sessions")


