1 year ago

How to handle a dummy user to replace a user?

Posted 1 year ago by shadrix

I'm not sure how to handle this the correct way.

Let us say we have messages table with dozens of messages from a user in a conversation.

Now, the user decides to leave the website and deletes his account. My "goal" is to completely delete the user from the user table (no soft-deleting) and update all relationships in all the tables I have. Especially, the messages table worries me, because it can be quite long.

How would you do this? Do you have one dummy user in the user table and just update all foreign keys to the dummy user?


Would this be enough? Where 1 would be a dummy user?

$table->foreign('user_id')->references('id')->on('users')->onDelete('set 1');

Please sign in or create an account to participate in this conversation.