23 lines
733 B
Python
23 lines
733 B
Python
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import BIGINT, TEXT, VARCHAR
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from db.base import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from db.models.sessions import Session
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(
|
|
BIGINT, unique=True, autoincrement=True, nullable=False, primary_key=True
|
|
)
|
|
username: Mapped[str] = mapped_column(TEXT, unique=True, nullable=True)
|
|
hashed_password: Mapped[str] = mapped_column(VARCHAR(255), nullable=True)
|
|
telegram_id: Mapped[int] = mapped_column(BIGINT, unique=True, nullable=True)
|
|
|
|
sessions: Mapped[list["Session"]] = relationship(back_populates="user", lazy="selectin")
|