A custom data class with one or more attributes was created and then assigned to a resource, such as Computers. Later, it is determined that one of the data class attributes (its fields) are no longer desired, or, changes to its structure are desired (such as changing the maximum length of a string attribute). As committed data classes are unable to be edited for the most part using the CMDB user interface, the user changes this manually using SQL Server Management Studio. Afterwards, the resources that have data in the deleted/modified attribute can no longer be edited and/or saved.
The metadata was not changed when the the data class was manually changed in SQL.
Edit the custom data class in the CMDB user interface by simply clicking on its "Save changes" button. This resaves the metadata with the current values, which should then enable editing of old resources and remove/change the affected fields.
(1) As this was caused by an unsupported manual SQL change, this may have caused severe issues with the database. If resaving the data class does not resolve the issue, the user may need to restore the database from a backup.
(2) It is strongly recommended that users carefully consider how they want their custom data classes to work before committing them to the database as this makes permanent changes. This has the potential to be a serious impact on the database depending on how the data classes are used in the system.
(3) If the user wants to, at their own risk, perform manual changes, it is strongly recommended to back up the database first, or if this cannot be done, at least back up the Inv_<custom data class_name> table before making changes.
If resaving the data class does not resolve the issue and the database or table cannot be resolved, it's possible that the data class will need to be recreated. This can be done by doing the following:
- Create a new custom data class with the now desired attributes.
- In SQL, write a script to copy data from the old data class to the new data class, skipping any deleted fields as necessary. For example,
INSERT INTO Inv_New_Custom_Data_Class_Name
SELECT _ResourceGuid, <other fileds to copy as well> -- Do not copy the _id field, as this is a unique field and will not be able to be copied.
Note: Please contact your DBA for assistance in using or modifying the above SQL script to be usable with the custom data classes involved.
- In CMDB, remove the old custom data class from being assigned to the resource, then add the new one.
- The old one can now be deleted under Data Classes.
- The only difference now is the changes as defined by the new custom data class, and its new name. Editing resources that had the old data class should now have the copied new data class values.
Imported Document Id