Soft deletion with PostgreSQL: but with logic on the database!

19-May-2022 1156
Any developer eventually faces a challenge: making significant changes to large code bases. But here, I’ll walk through an unorthodox solution which allows all the application code’s complexity to remain untouched thanks to the might and power of the underlying database! It’s soft deletion, but we’ll put the logic in the database itself. Keep reading for the ‘how’ and ‘why’!While this post is primarily about PostgreSQL, I’ll need to touch the application code a couple of times. Since Ruby on Rails is the stack I have the most experience with, I’ll be using it in my examples. Although Rubyists might have extra appreciation for this article, but let’s emphasize up front that the final solution will be completely in SQL.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle