What is the issue

This is an explanation of an issue why there are unexpected new or duplicate model categories after an instance is upgraded to KP11+ or LP3+ or Madrid.

What is the cause

When upgrading an instance, we are adding several model categories if they don't exist. Even if the names are the same as seeded model categories already exist, we don't want to delete or modify customer-created model categories. So we still add them and let customer to decide which (either their created model categories or our seeded model categories) are better for them. A fix script is added in KP11, LP3, and Madrid+. That is why there are duplicate model categories after upgrade to KP11+ or LP3+ or Madrid.

How to resolve

First, find out the new added seeded model categories. They can be found by filtering the categories on "Created by > is > system" or "admin", and "Created" (date/time) during the upgrading time frame.

If there are unexpected new model categories and they are unique, they can be deleted directly.

If there are unexpected duplicate model categories, then there are 2 options

  1. (Preferred) Keep the seeded model categories and delete the customer-created ones
    • Update seeded model categories with customer-expected values for Asset class and CI class.
    • Find all tables which are referencing to [cmdb_model_category]
      • Go to sys_db_object.list
      • Click into record with name "cmdb_model_category"
      • Click on "Show Schema Map"
      • Check "Show referencing tables" only
    • For each table, find which records have a reference to the duplicate customer-created model categories, and update them
      • This can be done by scripting. For example: (Please test this on a subprod instance before running it on product instance)
        var gr = new GlideRecord('table_name');
        gr.addQuery('column_name', 'CONTAINS', 'sys_id_of_customer_created_model_category');
        while (gr.next()) {
            var modelCategorySysIds = gr.getValue('column_name');
            gr.setValue('column_name', modelCategorySysIds.replace('sys_id_of_customer_created_model_category', 'sys_id_of_seeded_model_category');
    • Delete customer-created model categories
  2. Keep the customer-created model categories and delete the seeded ones
    • If you insist on keeping you model categories and want to delete the new added seeded ones, you can do that too. Usually, it happens when the customer has many tables and much data which are using customer-created model categories.

Option #1 is preferred, because it will keep the seeded model categories sys_id, which will be useful for troubleshooting in the future. The fix script is run once, so the next time when the instance is upgraded, model categories won't be added or updated again.

Article Information

Last Updated:2019-08-02 20:53:16