At present, there is a delete user function in the background, but because of many function modules, we need to clean up the records of users under multiple tables.
//清除该用户的所有发布的文章以及文章关联的标签 //清除该用户的所有关注的标签 //清除该用户的所有问题 //清除该用户的所有回答 //清除该用户的所有积分 //清除该用户的所有评论 //清除该用户的所有收藏 //清除该用户的所有问题关注 //清除该用户的所有私信 //清除该用户的所有消息通知 //清除该用户的所有草稿 //清除赠送给用户的所有邀请码 //清除该用户所有的邀请回答 //清除该用户的好友关系 //清空用户统计表 //清除用户的报名记录 ....
How do you generally deal with this, is it clear that the relevant information? Or to delete the user information to keep, just use the logo do not query??
Reply content:
At present, there is a delete user function in the background, but because of many function modules, we need to clean up the records of users under multiple tables.
//清除该用户的所有发布的文章以及文章关联的标签 //清除该用户的所有关注的标签 //清除该用户的所有问题 //清除该用户的所有回答 //清除该用户的所有积分 //清除该用户的所有评论 //清除该用户的所有收藏 //清除该用户的所有问题关注 //清除该用户的所有私信 //清除该用户的所有消息通知 //清除该用户的所有草稿 //清除赠送给用户的所有邀请码 //清除该用户所有的邀请回答 //清除该用户的好友关系 //清空用户统计表 //清除用户的报名记录 ....
How do you generally deal with this, is it clear that the relevant information? Or to delete the user information to keep, just use the logo do not query??
First of all, as you have said above, try not to delete important data.
Second, if you do need to implement the main table deletion, automatically remove the feature from the table. Just add a foreign key to the database and set it to on DELETE CASCADE.
This foreign key deletes the record that executes the deleted data from the table automatically when the primary table data is deleted. As long as the foreign key design is good. Main Table Delete a piece of data, a pile from the table followed by the deletion of the corpse cross ...
It is best to add a field to the table that identifies whether the record was deleted.
Set an IDENTITY field, identify the user as deleted, and then look for any user-related personal data that cannot be found and do not have to do too much. As for statistics and the like, you can add a judgment on whether the user is available.
I think also, the data must not be deleted, discouragement you want again that day. I can't do it without you.
A thing categorization malleability to her to delete dry and dry quietly
Placed in a database transaction, deleted together
Refer to Laravel Soft Delete to add a field delete_at default to null delete when update to current time
You dare delete the data?! I'm calling the cops!