You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from admin_app.db.models.base import AdminTimestampedModel
|
|
|
|
|
|
class StaffSession(AdminTimestampedModel):
|
|
__tablename__ = "staff_sessions"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
staff_account_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("staff_accounts.id"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
refresh_token_hash: Mapped[str] = mapped_column(
|
|
String(255),
|
|
unique=True,
|
|
index=True,
|
|
nullable=False,
|
|
)
|
|
expires_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
|
last_used_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
revoked_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
ip_address: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
user_agent: Mapped[str | None] = mapped_column(String(512), nullable=True)
|