illuminatech/db-safedelete
Illuminatech/db-safedelete adds safe, reversible deletion to Laravel Eloquent models. Instead of permanently removing records, it marks them as deleted, supports restoring them, and helps keep related data and queries consistent. Useful for audit-friendly apps that need recoverable deletes without c...
Architecture fit
SoftDeletes, not an architectural component. It overrides the deletion path on a model so that a caller-issued "hard delete" degrades to a soft delete when the database rejects the hard delete (typically an FK RESTRICT/NO ACTION violation).deleted_at column and uses SoftDeletes, and there is a real business case where some rows are orphaned (safe to purge) while others are referenced (must be retained). That is a narrow band — most models are either always-soft-delete or always-hard-delete.Integration feasibility
QueryException shape. Verify it against your Laravel major (10/11/12) before committing; expect to vendor or fork if it predates your version.Technical risk
25P02 current transaction is aborted). If the implementation catches the FK exception and then issues the soft UPDATE in the same transaction, it will fail on Postgres. It needs SAVEPOINT/savepoint semantics to be portable. MySQL/InnoDB tolerates this pattern; Postgres does not. Validate the engine before designing around it.forceDeleting/forceDeleted may fire before the fallback, then deleting/deleted fire. Observers, audit logs, activity feeds, webhooks, and queued listeners will see two deletion intents for one user action. This is the most likely source of production incidents.trashed(), which is a race unless inside the same transaction.$touches, cascadeOnDelete FKs, or application-level child cleanup may execute cleanup logic on the failed path and then again on the fallback path.NOASSERTION. This is a hard gate for most legal/procurement processes. It may just be a missing LICENSE file alongside an MIT declaration in composer.json, but it must be resolved in writing before adoption.Key questions
Stack fit
deleted_at column, and the SoftDeletes trait on each participating model. No queue, cache, or storage dependency.Migration path
softDelete(). The package adds value only for callers that genuinely cannot know in advance.Compatibility
app/ and drop the dependency.PRAGMA foreign_keys=ON; behavior will differ between test and production. SQL Server's error codes differ from MySQL's 23000, so any string/errno-based exception matching must be engine-aware.DB::transaction() closures.Sequencing
Maintenance
Support
delete() means delete.NOASSERTION license creates a procurement/compliance follow-up that will resurface at every audit if not documented.Scaling
DELETE (index/FK check work) followed by an UPDATE — roughly 2× the statement count on affected rows.DELETE still takes locks on the parent row and referenced indexes. High-volume bulk deletion of heavily-referenced parents can produce lock-wait and deadlock exposure that would not exist with an explicit soft delete upfront.Model::where(...)->delete()), verify the trait is even engaged — mass deletes bypass model events and may not route through the fallback. This is a likely blind spot.Failure modes
Ramp-up
How can I help you explore Laravel packages today?