| from sqlalchemy import text, Index, Integer, Text, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.models.base import Base | |
| class User(Base): | |
| __tablename__ = "users" | |
| id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) | |
| username: Mapped[str] = mapped_column(Text, unique=True, nullable=False) | |
| password_hash: Mapped[str] = mapped_column(Text, nullable=False) | |
| role: Mapped[str] = mapped_column(Text, default="admin") | |
| created_at: Mapped[str] = mapped_column(Text, server_default=text("CURRENT_TIMESTAMP")) | |
| __table_args__ = (Index("idx_users_username", "username"),) | |