Why I don't like soft delete

Updated: 15th September 2024
Tags: laravel programming database opinion

Improved Text

In most cases, soft deletes can lead to more trouble than profit. If your data doesn't include sensitive information like orders or payments, I personally prefer to use hard deletes.

However, before deleting any data, whether by a user or a moderator, I retrieve the model along with all its relationships and save it as a JSON object in a separate table, such as “deleted_items."

Why do I do this? I find it easier to manage than dealing with “zombie” rows in my tables.

That said, there are scenarios where having zombie rows is beneficial. For instance, in the context of payments, if you need to sum them up for statistics, you might consider retaining zombie users. Additionally, platforms like Reddit display “deleted” in place of the comment body, which illustrates another useful case for zombie comments.

In summary, there are very few occasions when retaining zombie deleted rows is necessary. Generally, hard deletes tend to be more maintainable and logical—at least in my experience.