User deletion fix

This commit is contained in:
Andrii V 2025-10-31 16:26:59 +01:00
parent 7d2a9d1d48
commit 7b315a1001

View file

@ -601,6 +601,10 @@ class UserModel(BaseModel):
if detach_artifacts:
self._detach_user_artifacts(user.username, user.artifacts, new_owner)
# Flush all detach operations to database before deleting user
# Ensures foreign keys are properly updated and prevents NULL constraint violations
self.sa.flush()
user_data = user.get_dict() # fetch user data before expire
# we might change the user data with detach/delete, make sure