26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
from sqlalchemy import Column, String, Boolean, DateTime, DECIMAL, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from app.core.database.db_session import Base
|
|
|
|
class UserSession(Base):
|
|
__tablename__ = "user_sessions"
|
|
|
|
session_id = Column(String(26), primary_key=True)
|
|
user_id = Column(String(26), ForeignKey("users.user_id", ondelete="CASCADE"), nullable=False)
|
|
device_name = Column(String(100), nullable=True)
|
|
device_type = Column(String(30), nullable=True)
|
|
browser = Column(String(50), nullable=True)
|
|
operating_system = Column(String(50), nullable=True)
|
|
ip_address = Column(String(45), nullable=False)
|
|
|
|
latitude = Column(DECIMAL(9, 6), nullable=True)
|
|
longitude = Column(DECIMAL(9, 6), nullable=True)
|
|
location_name = Column(String(150), nullable=True)
|
|
device_fingerprint = Column(String(255), nullable=True)
|
|
|
|
refresh_token = Column(String(255), unique=True, nullable=False)
|
|
access_token_id = Column(String(255), nullable=False)
|
|
expires_at = Column(DateTime, nullable=False)
|
|
last_activity = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|