27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from sqlalchemy import String, Integer, Text, Boolean, DateTime, Enum as SAEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from app.database import Base
|
|
import enum
|
|
|
|
|
|
class UserRole(str, enum.Enum):
|
|
player = "player"
|
|
creator = "creator"
|
|
admin = "admin"
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
email: Mapped[str] = mapped_column(String(255), unique=True, nullable=True)
|
|
nickname: Mapped[str] = mapped_column(String(50), nullable=True)
|
|
avatar_url: Mapped[str] = mapped_column(Text, nullable=True)
|
|
password_hash: Mapped[str] = mapped_column(String(255), nullable=True)
|
|
role: Mapped[str] = mapped_column(String(20), default=UserRole.player.value)
|
|
is_guest: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
game_count: Mapped[int] = mapped_column(Integer, default=0)
|
|
token_version: Mapped[int] = mapped_column(Integer, default=0)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow) |