Skip to content

Commit 92bbc8b

Browse files
committed
perf: The default definition is that email in User is not unique.
1 parent dab038e commit 92bbc8b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fastapi_user_auth/auth/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ class PasswordMixin(SQLModel):
4646

4747

4848
class EmailMixin(SQLModel):
49-
email: EmailStr = Field(None, title=_("Email"), unique=True, index=True, nullable=True, amis_form_item="input-email")
49+
"""If you need to define the email field as unique, you can achieve it by adding the following parameters in the subclass:
50+
__table_args__ = (UniqueConstraint("email", name="email"),)
51+
"""
52+
53+
email: EmailStr = Field(None, title=_("Email"), index=True, nullable=True, amis_form_item="input-email")
5054

5155

5256
class UserRoleLink(SQLModel, table=True):

0 commit comments

Comments
 (0)