From 66f33e91bd5a8e214b01495a0d74bcb54b13c0c9 Mon Sep 17 00:00:00 2001 From: atomi <1456417373@qq.com> Date: Thu, 14 Dec 2023 23:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96,=E4=BC=98?= =?UTF-8?q?=E5=8C=96sqlmodel=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi_user_auth/auth/models.py | 4 ++-- fastapi_user_auth/mixins/models.py | 10 ++++++---- pyproject.toml | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) 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