NBK xSP/RWF v12.0 upgrades should run these queries to clean up the database before upgrading.
NovaBACKUP xSP / Remote Workforce
Before upgrading version 11.X or 12.X to the next version (13.1 or 14.0), we recommend running the following SQL Queries with the Backup Server service shut down. If these queries are not run, you may receive the following errors during the upgrade:
"Unable to apply constraint file: dbo.ApfStoredVolumeFileHistory.FK_ApfStoredVolumeFileHistory_ApfStoredVolumeFiles.fkey.sql The ALTER TABLE statement conflicted with the FOREIGN KEY ..."
Query string:
--delete unused Administrator groups without user intervention
DELETE FROM groups WHERE GroupName='Administrators' AND (GroupId NOT IN (select GroupId from users))
--delete unused storage encryptions without user intervention
DELETE FROM ApfStorageEncryption WHERE ComputerAccId NOT IN (select ComputerAccId from ApfComputerAccount)
--delete unused computer accounts without user intervention
DELETE FROM apfstoredvolume WHERE DataSourceComputerAccId not in (select ComputerAccId from apfcomputeraccount)
--delete unused storage volumes without user intervention
DELETE FROM ApfStoredVolume WHERE ComputerAccId NOT IN (SELECT ComputerAccId from ApfComputerAccount)
--delete unused files without user intervention
DELETE FROM apfstoredvolumefiles WHERE StoredVolumeId NOT IN (SELECT StoredVolumeId FROM ApfstoredVolume)
--delete unused stored volume file histories without user intervention
DELETE FROM apfstoredvolumefilehistory WHERE StoredVolumeFileId NOT IN (SELECT FileId FROM apfstoredvolumefiles)