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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of PostgreSQL

PostgreSQL

Photo of soft deletes

soft deletes

Related news:

News photo

Don't rely on IF NOT EXISTS for concurrent index creation in PostgreSQL

News photo

PostgreSQL Sees Up To 4x Query Performance With SIMD-Optimized JSON Escaping

News photo

How to Get or Create in PostgreSQL