[Enhancement]: delete-user script: Allow deep delete #7682
Replies: 3 comments 1 reply
-
A more comprehensive deletion will be managed and possible by the Admin Panel: #3137 Though I agree, the script should also be more thorough @rubentalstra @berry-13 I could use help with this if either of you want to take it on |
Beta Was this translation helpful? Give feedback.
-
@danny-avila I can update the script to make this work. No problem! |
Beta Was this translation helpful? Give feedback.
-
Is this what you mean? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What features would you like to see added?
The current delete-user script only deletes the document from the
user
collection.It would be nice if the script support an optional arg that would delete records related to the user from other collections.
I think with mongoose that dependent documents can be sought out to avoid hard-coding of these dependencies.
More details
In addition to some poking around, I ran an AI analysis to see if there was some background job doing cleanup.
The config/delete-user.js script only deletes the user document from the User collection in MongoDB.
There is no evidence in this script of additional cleanup for other collections referencing this user.
View source
No scheduled job or cron script was found in the repository for orphan cleanup. There’s no mention of a recurring cleanup process in the package scripts or config files.
However, there is a script at e2e/setup/cleanupUser.ts that, given a user, explicitly deletes related data from multiple collections:
Deletes all user messages (deleteMessages).
Deletes all user sessions.
Deletes from User, Balance, and Transaction collections.
Deletes conversations and associated messages (deleteConvos).
This cleanup script appears to be used for test teardown, not as an automated or scheduled production cleanup:
View source
There are functions for deleting user-specific data in other models (e.g., deleteMessages, deleteConvos, deleteActions, deleteAllSharedLinks), but these are not invoked by the main delete-user script.
No evidence was found that these are run automatically after user deletion unless triggered manually or via test teardown.
No scheduled job (cron, interval, or workflow) was found that periodically cleans up orphaned documents.
No documentation or comments describe such a scheduled system.
Summary:
The standard delete-user script only removes the user record itself. There is no evidence of an automated or scheduled script that later cleans up orphaned documents in other collections. The only comprehensive cleanup found is in a manual/test teardown script, not used in normal operations.
If you need orphaned data removed in production, you will likely have to extend the delete-user script to invoke the relevant cleanup routines for other collections.
Which components are impacted by your request?
Other
Pictures
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions