title: Rails delayed_job: update existing job instead of creating new one?
body: <p>I'm using delayed_jobs gem to send a reminder notification to users phone an hour before his/hers reservation. </p>
  
  <p>This works fine unless the user decides to change the start time of the reservation. When the user changes the star time, delayed_job creates a new entry.  This is undesirable behaviour because the user also gets a reminder for the initial start time which has been changed. </p>
  
  <p>So what I want is to update the existing entry with the new start time or delete the first entry and create a new one. </p>
  
  <p>I'm thinking of adding a new column to the delayed_jobs tabel for the reservation id and doing something like this:</p>
  
  <pre><code> job = Delayed_jobs.where(:reservation_id =&gt; user.reservation.id)
  
  If job.present? 
   job.reservation_id=user.reservation.id
   job.save
  else
   # create new job
  end
  </code></pre>
  
  <p>I'm not sure if this is safe because of the locks that delayed_jobs performs. Is it possible to check if there is a lock? </p>
  
  <p>Also is there a better way of doing this? </p>