<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco" -->

---
title: Day 11/30 — Soft Delete with Care | daily.dev
description: Soft delete is more than adding a `deletedAt` column — it requires deliberate decisions about unique value reuse, relationship visibility, safe restoration,...
canonical: https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Day 11/30 — Soft Delete with Care | daily.dev
og:description: Soft delete is more than adding a `deletedAt` column — it requires deliberate decisions about unique value reuse, relationship visibility, safe restoration,...
og:url: https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco
og:image: https://api.daily.dev/og/posts/tYS2kHXCo.png
og:image:alt: Day 11/30 — Soft Delete with Care
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Day 11/30 — Soft Delete with Care

**[Nestjs Developers](https://daily.dev/sources/nestjsdevs)** · [@ezilemdodana](https://daily.dev/ezilemdodana) · 1 min read · 75 upvotes · 13 comments

## Summary

Soft delete is more than adding a `deletedAt` column — it requires deliberate decisions about unique value reuse, relationship visibility, safe restoration, privacy compliance, and consistent query filtering. Without clear rules, deleted records become ghosts that silently affect production logic. The post frames soft delete as a data-lifecycle decision and raises the question of when hard delete is the better choice.

## Content

Soft delete sounds simple: add `deletedAt` and hide the record.

Then the real questions arrive:

- Can its unique value be reused?
- Should deleted relationships still appear?
- Can the record be restored safely?
- Does “deleted” satisfy privacy requirements?
- Will every query apply the correct filter?

Soft delete is a data-lifecycle decision, not just a decorator.

Without clear rules, your database slowly fills with ghosts that still affect production logic.

When do you choose hard delete instead?

#NestJS #TypeORM #DataDesign

## Community discussion

Top comments from developers on daily.dev.

**@rzaasadov** · 6 upvotes

> It depends on kind of data. As a developer of messenger software we do that:
> 1) if user deletes messages - hard delete
>
> 2) if user deletes content - video or file or image - soft delete when scheduled hard delete
>
> 3) if something deleted from admin panel then moving to  archive  warehouse.

**@mdshafinahmed** · 2 upvotes

> Good Things brother.
> Thank you for sharing.

**@gaburayondev** · 2 upvotes

> The unique-constraint question is the one people miss until it bites them in production — a partial unique index scoped to `deletedAt IS NULL` fixes reuse, but most teams don't add it until the first duplicate-key error on a "deleted" record. On hard delete: I go there whenever "deleted" needs to satisfy an actual legal erasure requirement (GDPR right-to-erasure), or when the entity has no downstream relational meaning after deletion — soft delete's entire value is preserving referential/audit history, so if you don't need that history, you're just paying query-filter overhead for nothing.

**@trevorsuna** · 1 upvotes

> The uniqueness and retention rules are where soft delete stops being a small schema change. I like defining restore, purge, and legal-retention behavior first, then designing indexes and queries around those rules so deleted rows cannot quietly affect production logic.

**@davym242** · 1 upvotes

> In case of fintech solution, do you think that hard deletion must be used just in case of explicit demand of user ?

## Similar posts on daily.dev

- [The challenges of soft delete](https://daily.dev/posts/the-challenges-of-soft-delete-gfrwefogi) · Hacker News · 7 upvotes · 1 comments
- [Implementing Soft Deletes in Java](https://daily.dev/posts/implementing-soft-deletes-in-java-6jgaa5uhu) · Foojay.io · 1 upvotes · 0 comments
- [Introducing Soft Delete for Tigris Buckets and Objects](https://daily.dev/posts/introducing-soft-delete-for-tigris-buckets-and-objects-sll6gohug) · Tigris · 4 upvotes · 0 comments

---

Tags: [#nodejs](https://daily.dev/tags/nodejs), [#backend](https://daily.dev/tags/backend), [#nestjs](https://daily.dev/tags/nestjs)

[View this post on daily.dev](https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco","headline":"Day 11/30 — Soft Delete with Care","text":"Soft delete is more than adding a `deletedAt` column — it requires deliberate decisions about unique value reuse, relationship visibility, safe restoration, privacy compliance, and consistent query filtering. Without clear rules, deleted records become ghosts that silently affect production logic. The post frames soft delete as a data-lifecycle decision and raises the question of when hard delete is the better choice.","url":"https://daily.dev/posts/day-11-30-soft-delete-with-care-tys2khxco","datePublished":"2026-08-07T09:17:52.296Z","dateModified":"2026-08-07T09:18:10.268Z","author":{"@type":"Person","name":"Ezile Mdodana","url":"https://daily.dev/ezilemdodana","image":"https://media.daily.dev/image/upload/s--1OI8gwnO--/f_auto/v1771923757/avatars/avatar_7vB9SeLRKhOHGnzEpmFvQ?_a=BAMAMiiu0","description":"Software Project Lead sharing practical insights on NestJS, Angular, AWS and scalable systems.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":8420}},"image":"https://media.daily.dev/image/upload/s--Ej7oMBaL--/f_auto/v1786094273/posts/tYS2kHXCo?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":75},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":13}],"comment":[{"@type":"Comment","text":"It depends on kind of data. As a developer of messenger software we do that:\n\n\nif user deletes messages - hard delete\n\n\nif user deletes content - video or file or image - soft delete when scheduled hard delete\n\n\nif something deleted from admin panel then moving to  archive  warehouse.","datePublished":"2026-08-07T12:10:58.422Z","url":"https://daily.dev/posts/tYS2kHXCo#c-wFt1qoibu","author":{"@type":"Person","name":"Rza Asadov","url":"https://daily.dev/rzaasadov","image":"https://media.daily.dev/image/upload/s--obkknPEU--/f_auto/v1784480937/avatars/avatar_BPb4HehqaZ95FfYqQyzvN?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6}},{"@type":"Comment","text":"Good Things brother.\nThank you for sharing.","datePublished":"2026-08-08T02:52:43.378Z","url":"https://daily.dev/posts/tYS2kHXCo#c-ZwFCyzSlS","author":{"@type":"Person","name":"Md. Shafin Ahmed","url":"https://daily.dev/mdshafinahmed","image":"https://media.daily.dev/image/upload/s---a0uwu1i--/f_auto/v1783046504/avatars/avatar_u8iR8DacSYjsphyDqQTQ9?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"The unique-constraint question is the one people miss until it bites them in production — a partial unique index scoped to deletedAt IS NULL fixes reuse, but most teams don’t add it until the first duplicate-key error on a “deleted” record. On hard delete: I go there whenever “deleted” needs to satisfy an actual legal erasure requirement (GDPR right-to-erasure), or when the entity has no downstream relational meaning after deletion — soft delete’s entire value is preserving referential/audit history, so if you don’t need that history, you’re just paying query-filter overhead for nothing.","datePublished":"2026-08-08T06:39:16.005Z","url":"https://daily.dev/posts/tYS2kHXCo#c-4juHxTKmo","author":{"@type":"Person","name":"Gabu Rayon Dev","url":"https://daily.dev/gaburayondev","image":"https://media.daily.dev/image/upload/s--5hPC52y_--/f_auto/v1773412842/avatars/avatar_8fkdziGASnSSBES6c4Ml9?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"The uniqueness and retention rules are where soft delete stops being a small schema change. I like defining restore, purge, and legal-retention behavior first, then designing indexes and queries around those rules so deleted rows cannot quietly affect production logic.","datePublished":"2026-08-08T04:35:30.341Z","url":"https://daily.dev/posts/tYS2kHXCo#c-Z0aJ5eiZy","author":{"@type":"Person","name":"Trevor Suna","url":"https://daily.dev/trevorsuna","image":"https://media.daily.dev/image/upload/s--dZ7gXxpp--/f_auto/v1784081551/avatars/avatar_EMoP47rpuw8DNjhp6R1b6?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"In case of fintech solution, do you think that hard deletion must be used just in case of explicit demand of user ?","datePublished":"2026-08-07T15:08:38.964Z","url":"https://daily.dev/posts/tYS2kHXCo#c-LbRDVtVzB","author":{"@type":"Person","name":"Davy","url":"https://daily.dev/davym242","image":"https://media.daily.dev/image/upload/s--v66bVlAD--/f_auto/v1751537974/avatars/avatar_lBu8VCAxPduu5ftqW3tAR?_a=BAMClqZW0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/nestjsdevs","name":"Nestjs Developers"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nestjs Developers","item":"https://daily.dev/squads/nestjsdevs"},{"@type":"ListItem","position":3,"name":"Day 11/30 — Soft Delete with Care"}]}
```

