Skip to content
Prompt Words
History

Soft delete

Also called: logical delete, trash, deleted_at flag.

Deleting marks a row as deleted, for example by setting a deleted_at date, instead of removing it. Normal queries hide it, and it can be restored or cleaned up for good later.

Soft delete sets deleted_at instead of removing the row. The list hides the row, but it stays in the table, so it can be restored. Delete forever, or the cleanup job 30 days later, removes it for real.

List: 3 projects · Table: 3 rows

Nothing deleted yet. The list and the table both have 3 projects.

    All live

    Say it in a prompt

    Use soft delete for comments. Set deleted_at instead of removing the row, add deleted_at IS NULL to every list and count query, show "This comment was deleted" where a reply still points to it, and let admins restore it for 14 days.

    Vague vs precise prompt

    Vague prompt

    add a delete button for projects

    Typical resultAdds DELETE /projects/:id that runs a SQL DELETE. One wrong click removes the project, its tasks and its history for good, with no way back.

    Precise prompt

    Soft-delete projects: add a nullable deleted_at column, make DELETE /projects/:id set it to now(), hide rows with deleted_at from all normal queries, add POST /projects/:id/restore, and remove rows deleted more than 30 days ago in a nightly job.

    Typical resultDeleted projects leave every list but can be restored for 30 days; after that the nightly job removes them for good.

    Seen on

    • Laravel: Eloquent's SoftDeletes trait sets a deleted_at column instead of removing the row, leaves those rows out of queries, and restore() brings them back.

    You might describe it as

    • put it in the trash instead of deleting forever
    • let people undo a delete
    • keep the row but hide it

    Not to be confused with

    • Audit log

      A soft delete keeps the deleted row so it can come back; an audit log keeps a record of who deleted it and when.