29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from typing import Optional, TYPE_CHECKING
|
|
|
|
from sqlalchemy import String, BigInteger, Integer, Boolean
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.core.database import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from src.models.tasks import TasksORM
|
|
|
|
|
|
class UsersORM(Base):
|
|
__tablename__ = "users"
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
username: Mapped[str] = mapped_column(
|
|
String(30), nullable=False, unique=True, index=True
|
|
)
|
|
hashed_password: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
email: Mapped[Optional[str]] = mapped_column(
|
|
String(255), unique=True, nullable=True
|
|
)
|
|
telegram_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
avatar_path: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
|
is_superuser: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
tasks: Mapped[list["TasksORM"]] = relationship(
|
|
back_populates="user", cascade="all, delete-orphan"
|
|
)
|