Can someone tell me precisely how to integrate acts_as_paranoid
with DelayedJob
? I've tried creating a class Delayed::Backend::ActiveRecord::Job
and adding acts_as_paranoid
to it but even if I use an initializer and require
the new class, acts_as_paranoid doesn't seem to do anything.
I'm not getting any errors so paranoia
seems to be installed correctly and the job is cleanly deleted when it completes successfully - which is of course what I'm trying to prevent.
Happy to try any debugging suggestions if nobody reads this and immediately knows how I've screwed up.
I know you answered your own question, sort of, but your answer doesn't help people landing here looking to actually integrate
DelayedJob
withacts_as_paranoid
so I thought I'd explain this for others.Create migration to add
deleted_at
todelayed_jobs
:Run migrations:
Extend the
Delayed::Job
class to addacts_as_paranoid
:config/initializers/delayed_job.rb
That's it!
Now when a job gets completed, you'll see that it doesn't get removed from the
delayed_jobs
table, it just gets a timestamp put in thedeleted_at
column so that the workers don't pick it up.ProTip: The
deleted_at
column indicates when the job was completed as well.