Get the latest tech news
Soft Deletes with Ecto and PostgreSQL
This article details how to implement soft-delete in Ecto using PostgreSQL rules and views
Therefore, if soft deletion plays an important role in your application and applies to several resources, then enforcing it at the database level can be much more robust, as you guarantee no one can accidentally remove this data unintentionally. When migrating, we create a soft_deletion rule on the orders table that effectively replaces the deletion by an update statement that sets the deleted_at column. The technique shown here is useful when you want to keep deleted in the same table (and therefore with the same constraints and foreign keys) as regular data, often for historical reasons.
Or read this on Hacker News