Yang data model from container to list

In the present yang model, a container is defined:

container top {
     container c1 {
      leaf v1 { type string;}
      leaf v2 { type uint16;}
     }
}

in the next revision, there is need to make the top container to list:

list top {
     key name;
     leaf name  {type string;}

     container c1 {
      leaf v1 { type string;}
      leaf v2 { type uint16;}
     }
}

After this change, loading of old cdb files will fail because of schema change. To be able load the old cdb even after schema change, is there any way out? Please clarify.

As far as I can see, the loading of the CDB files doesn’t (and shouldn’t) fail - but of course the old contents of the c1 container will be discarded, since there is no way the automatic CDB upgrade can handle this change - it can’t just invent a key for your list entry.

But you can preserve the c1 contents - possibly by using the method described in the section “Using initialization files for upgrade” in the CDB chapter of the User Guide (only really applicable if the data in c1 is “static” and hasn’t been changed by the user), and definitely by using the method described in the section “Using MAAPI to modify CDB during upgrade”. With the MAAPI method, you would create a top list entry with a key of your choice via MAAPI, and then read the contents of the “old” c1 container via CDB, and write it to the “new” c1 container via MAAPI.