Hangfire Discussion

Deleting a recurring task via SQL script

recurring
sql-server
Tags: #<Tag:0x00007f85071013d0> #<Tag:0x00007f85071011f0>

#1

I’m looking for a way to maintain my applications recurring tasks via db scripts. Does anyone know what SQL I need to run to reliably delete a recurring task?


#2

The code to call the removal is here. Assuming you are referring to sql server, a delete script would look like this:
declare @key nvarchar(100) = ‘recurring-job:{recurringJobId}’
delete from [Hangfire].Hash where [Key] = @key
as seen here replacing the recurringJobId with the name of your recurring job (name is id for recurring jobs)

Then you’d need to run this for the set:
declare @value nvarchar(256) = ‘{recurringJobId}’
delete from [Hangfire].[Set] where [Key] = ‘recurring-jobs’ and Value = @value
as seen here

There are similar classes for different storages.