diff --git a/fastapi_user_auth/auth/models.py b/fastapi_user_auth/auth/models.py index 21402c7..be1cfb8 100644 --- a/fastapi_user_auth/auth/models.py +++ b/fastapi_user_auth/auth/models.py @@ -21,8 +21,8 @@ class BaseUser(PkMixin, CUDTimeMixin, UsernameMixin, PasswordMixin, EmailMixin): __tablename__ = "auth_user" is_active: bool = Field(default=True, title=_("Is Active")) - nickname: str = Field("", title=_("Nickname"), max_length=40) - avatar: str = Field( + nickname: Optional[str] = Field("", title=_("Nickname"), max_length=40) + avatar: Optional[str] = Field( "", title=_("Avatar"), max_length=255, diff --git a/fastapi_user_auth/mixins/models.py b/fastapi_user_auth/mixins/models.py index 50760f5..7447e6a 100644 --- a/fastapi_user_auth/mixins/models.py +++ b/fastapi_user_auth/mixins/models.py @@ -1,28 +1,30 @@ from datetime import datetime from typing import Optional -from fastapi_amis_admin.models.fields import Field +from fastapi_amis_admin.models import Field, SQLModel from fastapi_amis_admin.utils.translation import i18n as _ from pydantic import EmailStr, SecretStr from sqlalchemy import func from sqlmodel import AutoString -from sqlmodelx import SQLModel from fastapi_user_auth.utils.sqltypes import SecretStrType class PkMixin(SQLModel): - id: Optional[int] = Field(default=None, title="ID", primary_key=True, nullable=False) + id: Optional[int] = Field( + default=None, title="ID", primary_key=True, nullable=False, sa_column_kwargs={"autoincrement": True} + ) class CreateTimeMixin(SQLModel): - create_time: datetime = Field(default_factory=datetime.now, title=_("Create Time")) + create_time: datetime = Field(default_factory=datetime.now, title=_("Create Time"), index=True) class UpdateTimeMixin(SQLModel): update_time: Optional[datetime] = Field( default_factory=datetime.now, title=_("Update Time"), + index=True, sa_column_kwargs={"onupdate": func.now(), "server_default": func.now()}, ) diff --git a/pyproject.toml b/pyproject.toml index cbefed7..a77b450 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,10 +36,10 @@ classifiers = [ "Programming Language :: Python :: 3.11", ] dependencies = [ - "fastapi-amis-admin>=0.6.0,<0.8.0", + "fastapi-amis-admin>=0.7.0a2,<0.8.0", "email-validator>=1.3.1,<3.0.0", "passlib>=1.7.4", - "bcrypt>=4.0.0", + "bcrypt>=4.0.0,<4.1.0", "casbin>=1.29.0", ] @@ -65,7 +65,7 @@ test = [ "pre-commit>=2.20.0", "httpx>=0.23.3", "pydantic-settings>=2.0.0", - "fastapi-amis-admin>=0.7.0a1", + "fastapi-amis-admin>=0.7.0a2", ] # pytest