38 lines
818 B
Python
38 lines
818 B
Python
from enum import Enum
|
|
|
|
from sqlalchemy import String, Boolean, Enum as SQLEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from db.base import Base
|
|
|
|
class UserRole(str, Enum):
|
|
ADMIN = "admin"
|
|
GROUP_MANAGER = "group_manager"
|
|
MEMBER = "member"
|
|
|
|
class User(Base):
|
|
username: Mapped[str] = mapped_column(
|
|
String(50),
|
|
unique=True,
|
|
index=True,
|
|
nullable=False,
|
|
)
|
|
|
|
secret_hash: Mapped[str] = mapped_column(
|
|
String(255),
|
|
nullable=False,
|
|
)
|
|
|
|
role: Mapped[UserRole] = mapped_column(
|
|
SQLEnum(UserRole, name="user_role"),
|
|
default=UserRole.MEMBER,
|
|
index=True,
|
|
nullable=False,
|
|
)
|
|
|
|
is_active: Mapped[bool] = mapped_column(
|
|
Boolean,
|
|
default=True,
|
|
index=True,
|
|
nullable=False,
|
|
) |