Skip to content

Instantly share code, notes, and snippets.

@imarlovic
Created February 8, 2021 23:46
Show Gist options
  • Select an option

  • Save imarlovic/70acc6e11db90aeca8db86b0834e7dd8 to your computer and use it in GitHub Desktop.

Select an option

Save imarlovic/70acc6e11db90aeca8db86b0834e7dd8 to your computer and use it in GitHub Desktop.

Revisions

  1. imarlovic created this gist Feb 8, 2021.
    59 changes: 59 additions & 0 deletions drop_hangfire_tables.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    GO
    PRINT N'Dropping [HangFire].[FK_HangFire_State_Job]...';
    GO
    ALTER TABLE [HangFire].[State] DROP CONSTRAINT [FK_HangFire_State_Job];
    GO
    PRINT N'Dropping [HangFire].[FK_HangFire_JobParameter_Job]...';
    GO
    ALTER TABLE [HangFire].[JobParameter] DROP CONSTRAINT [FK_HangFire_JobParameter_Job];
    GO
    PRINT N'Dropping [HangFire].[Schema]...';
    GO
    DROP TABLE [HangFire].[Schema];
    GO
    PRINT N'Dropping [HangFire].[Job]...';
    GO
    DROP TABLE [HangFire].[Job];
    GO
    PRINT N'Dropping [HangFire].[State]...';
    GO
    DROP TABLE [HangFire].[State];
    GO
    PRINT N'Dropping [HangFire].[JobParameter]...';
    GO
    DROP TABLE [HangFire].[JobParameter];
    GO
    PRINT N'Dropping [HangFire].[JobQueue]...';
    GO
    DROP TABLE [HangFire].[JobQueue];
    GO
    PRINT N'Dropping [HangFire].[Server]...';
    GO
    DROP TABLE [HangFire].[Server];
    GO
    PRINT N'Dropping [HangFire].[List]...';
    GO
    DROP TABLE [HangFire].[List];
    GO
    PRINT N'Dropping [HangFire].[Set]...';
    GO
    DROP TABLE [HangFire].[Set];
    GO
    PRINT N'Dropping [HangFire].[Counter]...';
    GO
    DROP TABLE [HangFire].[Counter];
    GO
    PRINT N'Dropping [HangFire].[Hash]...';
    GO
    DROP TABLE [HangFire].[Hash];
    GO
    PRINT N'Dropping [HangFire].[AggregatedCounter]...';
    GO
    DROP TABLE [HangFire].[AggregatedCounter];
    GO
    PRINT N'Dropping [HangFire]...';
    GO
    DROP SCHEMA [HangFire];
    GO
    PRINT N'Update complete.';
    GO
    9 changes: 9 additions & 0 deletions reset_hangfire_database.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    TRUNCATE TABLE [HangFire].[AggregatedCounter]
    TRUNCATE TABLE [HangFire].[Counter]
    TRUNCATE TABLE [HangFire].[JobParameter]
    TRUNCATE TABLE [HangFire].[JobQueue]
    TRUNCATE TABLE [HangFire].[List]
    TRUNCATE TABLE [HangFire].[State]
    DELETE FROM [HangFire].[Job]
    DBCC CHECKIDENT ('[HangFire].[Job]', reseed, 0)
    UPDATE [HangFire].[Hash] SET Value = 1 WHERE Field = 'LastJobId'