feat: add User model and Alembic migration for users table
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
username: Mapped[str] = mapped_column(String(64), unique=True, nullable=False, index=True)
|
||||
full_name: Mapped[str] = mapped_column(String(128), nullable=False, default="")
|
||||
email: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
department: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
role: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
pw_hash: Mapped[str | None] = mapped_column(String(256), nullable=True)
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
is_admin: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
account_expires: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
last_login: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, server_default=func.now(), nullable=False
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, server_default=func.now(), onupdate=func.now(), nullable=False
|
||||
)
|
||||
Reference in New Issue
Block a user