Skip to content

Soft Delete

Easy — everyone uses thisDatabase

ELI5 — The Vibe Check

A soft delete is marking something as deleted without actually deleting it — like putting a file in the trash instead of permanently deleting it. You add a deleted_at timestamp and filter it out of queries. The data is still there if you need it back. It's the undo button for your database. The downside? Your database keeps growing and queries get more complex.

Real Talk

Soft delete is a data management pattern where records are flagged as deleted (typically via a deleted_at timestamp or is_deleted boolean) rather than physically removed. Benefits include audit trails, easy recovery, and referential integrity preservation. Drawbacks include query complexity (every query needs a filter), storage growth, and potential GDPR compliance issues where actual deletion is required.

Show Me The Code

-- Soft delete: mark as deleted
UPDATE users SET deleted_at = NOW() WHERE id = 123;

-- Query active users only
SELECT * FROM users WHERE deleted_at IS NULL;

-- Restore a soft-deleted user
UPDATE users SET deleted_at = NULL WHERE id = 123;

When You'll Hear This

"We use soft deletes for users — you can always restore an account." / "Soft deletes are great until your table has 10 million 'deleted' rows."

Made with passive-aggressive love by manoga.digital. Powered by Claude.