Skip to content

soft_delete

File: schema/mixins/soft_delete.yaml

Adds a deleted_at nullable timestamp for soft-delete.

No parametersdeleted_at references nothing app-specific.

ColumnTypeNullNotes
deleted_attimestamptzNULLNULL = active, non-NULL = archived

App-layer reads add WHERE deleted_at IS NULL to exclude archived rows by default; an explicit opt-in (e.g. ?include_archived=true) bypasses the filter.

  • RLS is unchanged — soft-delete is a visibility concern, not an authorization one.
  • Unique indexes that must permit reuse of a value after archive should be partial: where: "deleted_at IS NULL".

When a table also carries audit_log, transitions on deleted_at produce lifecycle markers in the audit_log table (in addition to the per-column diff row for deleted_at itself being skipped — it’s one of the stamp columns audit_diff ignores):

Transitionaudit_log __row__ marker
deleted_at NULL → setactive → archived
deleted_at set → NULLarchived → restored
mixins: [audit, audit_log, soft_delete]