SPDocKit v5.2 – data retention not working properly

Summary: I receive the following error when running the data retention:

The DELETE statement conflicted with the REFERENCE constraint "FK_WorkflowDefinitions_LoadingInfos". 

This error will appear if you try to run the data retention job on SPDocKit data records containing workflow information.

Application Version: 5.2.0

Solution: In order to resolve this problem, please execute the following query on your SPDocKit database. This query will update SPDocKit database settings which will allow data retention job to execute properly.

Download this script

GO
PRINT N'Dropping foreign keys from [dbo].[LoadedPrincipals]'
GO
ALTER TABLE [dbo].[LoadedPrincipals] DROP CONSTRAINT[FK_LoadedPrincipals_LoadingInfos]
GO
PRINT N'Dropping foreign keys from [dbo].[WorkflowDefinitions]'
GO
ALTER TABLE [dbo].[WorkflowDefinitions] DROP CONSTRAINT[FK_WorkflowDefinitions_LoadingInfos]
GO
PRINT N'Dropping foreign keys from [dbo].[WorkflowSubscriptions]'
GO
ALTER TABLE [dbo].[WorkflowSubscriptions] DROP CONSTRAINT[FK_WorkflowSubscriptions_WorkflowDefinitions]

GO
PRINT N'Adding foreign keys to [dbo].[LoadedPrincipals]'
GO
ALTER TABLE [dbo].[LoadedPrincipals] ADD CONSTRAINT [FK_LoadedPrincipals_LoadingInfos] FOREIGN KEY ([LoadingInfoID]) REFERENCES [dbo].[LoadingInfos] ([ID]) ON DELETE CASCADE
GO
PRINT N'Adding foreign keys to [dbo].[WorkflowDefinitions]'
GO
ALTER TABLE [dbo].[WorkflowDefinitions] ADD CONSTRAINT [FK_WorkflowDefinitions_LoadingInfos] FOREIGN KEY ([LoadingInfoID]) REFERENCES [dbo].[LoadingInfos] ([ID]) ON DELETE CASCADE
GO
PRINT N'Adding foreign keys to [dbo].[WorkflowSubscriptions]'
GO
ALTER TABLE [dbo].[WorkflowSubscriptions] ADD CONSTRAINT [FK_WorkflowSubscriptions_WorkflowDefinitions] FOREIGN KEY ([WorkflowDefinitionID]) REFERENCES [dbo].[WorkflowDefinitions] ([ID]) ON DELETE CASCADE

Status: Solved in version 5.3.