JUL6ART
🇬🇧 EN
Retour au blog
23 April 2026

Soft-delete by default: no silent loss

Every business entity is restorable, and only super-admins can do it.

When a user deletes a contact, a deal, a page or a comment, two things must never happen: (1) the data vanishes from disk with no recourse, (2) the data is still visible in listings after deletion.

Jul6art applies the soft-delete pattern to every business entity:

  • The SoftDeletableTrait trait adds the deleted_at column and the softDelete() / restore() methods.
  • A global Doctrine soft_delete filter automatically excludes deleted_at IS NOT NULL rows from every query — except for ROLE_SUPER_ADMIN who sees the full picture.
  • The restore route /admin/.../{id}/restore is gated by ROLE_SUPER_ADMIN: no tenant admin can restore.
  • On UNIQUE columns (a Contact email), the value is suffixed with _DELETED_<timestamp> at soft-delete time to free the constraint while preserving the trace.
  • The event pairs BEFORE_SOFT_DELETED / AFTER_SOFT_DELETED + BEFORE_RESTORED / AFTER_RESTORED are dispatched on every operation, with an abort() contract that lets a listener block the deletion.

Result: an accidental delete is recoverable in two super-admin clicks, and no trace is ever lost.