forked from FOSS/ASF-Control-Bot
28 lines
965 B
Python
28 lines
965 B
Python
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import BigInteger, Boolean, DateTime, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from bot.db.base import Base
|
|
|
|
|
|
def utc_now() -> datetime:
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
telegram_id: Mapped[int] = mapped_column(BigInteger, unique=True, index=True)
|
|
username: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
first_name: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
last_name: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
is_admin: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utc_now)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
default=utc_now,
|
|
onupdate=utc_now,
|
|
)
|