Files
Shubhankar45 53dbfa976b -
2026-11-13 12:14:55 +00:00

22 lines
878 B
Python

from datetime import datetime
from sqlalchemy import Boolean, DateTime, String, true
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin
from app.models.enums import AdminRole, db_enum
class Admin(TimestampMixin, Base):
__tablename__ = "admins"
id: Mapped[int] = mapped_column(primary_key=True)
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
full_name: Mapped[str] = mapped_column(String(150))
hashed_password: Mapped[str] = mapped_column(String(255))
role: Mapped[AdminRole] = mapped_column(
db_enum(AdminRole, "admin_role"), default=AdminRole.ADMIN, server_default=AdminRole.ADMIN.value
)
is_active: Mapped[bool] = mapped_column(Boolean, default=True, server_default=true())
last_login_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))