module SoftDeletable
Soft-deletes a record by stamping +deleted_at+ instead of removing the row.
The record and everything that points at it (steps, execution history, foreign keys) survive, so history and audit trails stay intact. A new record can then be created for the same logical slot โ callers must scope their lookups with +kept+ (there is deliberately no +default_scope+, matching the rest of the codebase) and the owning table needs a partial unique index (+where: โdeleted_at IS NULLโ+) so a discarded row does not block a fresh one.
Include it on a model that has a +deleted_at+ datetime column:
class MaintenancePlan < ApplicationRecord include SoftDeletable end