Within our project we changed a category definition which affects more than 1.000.000 nodes. No naming and types are changed, nor are fields removed or added. Only the look-up definition of one of the fields have changed.
From my part of view only LLAttrData and LLAttrBlobData needs to be updated to get the new version of the category active. We decided to skip the DAuditNew table. Did anyone performed such update before, or sees any problems?
Category id = 42256 with a latest version of 49. Version 47 and 48 are identical, looking at the field names and types. Only the last version of the Node should be updated.
-- Update to cat version 49 in case last version of the object have category version 47 or 48.
UPDATE L2S_DBAdmin.LLAttrData
SET DefVerN = 49
OUTPUT inserted.ID, inserted.VerNum, deleted.DefVerN as OldDefVerN, inserted.DefVerN as NewDefVerN
WHERE defid = 42256 AND (DefVerN = 47 OR DefVerN = 48)
AND EXISTS (
SELECT DataID
FROM L2S_DBAdmin.Dtree as d
WHERE LLAttrData.ID = d.DataID AND LLAttrData.VerNum = d.VersionNum
)
-- Update the category ASSOC. Version 47 will be upgraded to 49
UPDATE L2S_DBAdmin.LLAttrBlobData
SET SegmentBlob = Replace(cast(SegmentBlob as nvarchar(max)), '{42256,47}','{42256,49}' )
OUTPUT inserted.ID, inserted.VerNum
WHERE
EXISTS (
SELECT DataID
FROM L2S_DBAdmin.Dtree as d
WHERE LLAttrBlobData.ID = d.DataID AND LLAttrBlobData.VerNum = d.VersionNum
) AND CharIndex('{42256,47}',Cast(SegmentBlob as nvarchar(max))) > 0
-- Update the category ASSOC. Version 48 will be upgraded to 49
UPDATE L2S_DBAdmin.LLAttrBlobData
SET SegmentBlob = Replace(cast(SegmentBlob as nvarchar(max)), '{42256,48}','{42256,49}' )
OUTPUT inserted.ID, inserted.VerNum
WHERE
EXISTS (
SELECT DataID
FROM L2S_DBAdmin.Dtree as d
WHERE LLAttrBlobData.ID = d.DataID AND LLAttrBlobData.VerNum = d.VersionNum
) AND CharIndex('{42256,48}',Cast(SegmentBlob as nvarchar(max))) > 0