24 lines
893 B
Python
24 lines
893 B
Python
from typing import Optional, TYPE_CHECKING
|
|
|
|
from fastapi_users_db_sqlalchemy import SQLAlchemyBaseUserTable
|
|
from sqlalchemy import String, BigInteger, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.db.database import Base
|
|
|
|
|
|
class Users(SQLAlchemyBaseUserTable[int], Base):
|
|
__tablename__ = "users"
|
|
if TYPE_CHECKING:
|
|
from src.models.tasks import Tasks
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
name: Mapped[Optional[str]] = mapped_column(
|
|
String(30), nullable=False, unique=True, index=True
|
|
)
|
|
email: Mapped[Optional[str]] = mapped_column(String(320), nullable=True)
|
|
telegram_id: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
avatar_path: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
|
|
|
tasks: Mapped[list["Tasks"]] = relationship(back_populates="user")
|