🔧 fix(api_key.py): remove unnecessary sa_relationship_kwargs to improve code readability and maintainability
🔧 fix(user.py): add sa_relationship_kwargs to api_keys relationship to enable cascading delete when deleting a user
This commit is contained in:
parent
1e0f81c135
commit
62a4e94c71
2 changed files with 4 additions and 2 deletions
|
|
@ -26,7 +26,6 @@ class ApiKey(ApiKeyBase, table=True):
|
|||
user_id: UUID = Field(index=True, foreign_key="user.id")
|
||||
user: "User" = Relationship(
|
||||
back_populates="api_keys",
|
||||
sa_relationship_kwargs={"cascade": "delete"},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ class User(SQLModelSerializable, table=True):
|
|||
create_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
updated_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
last_login_at: Optional[datetime] = Field()
|
||||
api_keys: list["ApiKey"] = Relationship(back_populates="user")
|
||||
api_keys: list["ApiKey"] = Relationship(
|
||||
back_populates="user",
|
||||
sa_relationship_kwargs={"cascade": "delete"},
|
||||
)
|
||||
flows: list["Flow"] = Relationship(back_populates="user")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue