...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
databaseChangeLog: - changeSet: author: cps label: xnf-data-preload id: 14.1 loadUpdateData: encoding: UTF-8 file: 'changelog/db/changes/data/test_table.csv' onlyUpdate: 'false' primaryKey: 'id' quotchar: '"' separator: '|' tableName: 'test_table' |
test table with data
Modifying CPS Client-
...
Tables (Yang Modules)
Because of the generic way CPS stores any client data using Yan Yang Modules often schema changes only affect these yang modules and the associated data not the actual Postgress DB schema!
The following sections describe how such changes could be implemented using Liquibase.
...
To load a yang resource, create a new yang resource csv file to load the data (as outlined above) in the following format 'yang_resource_@*revision*' (the revision is usually the date -of-creation*'of the change in the format yyyy-mm-dd)
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
name|content|checksum dmi-registry@2021-12-13.yang|"module dmi-registry { yang-version 1.1; namespace \"org:onap:cps:ncmp\"; prefix dmi-reg; organization \"Nordix Foundation\"; contact \"rahul.tyagi@est.tech\"; revision \"2021-12-13\" { description \"Added new list of public additonal properties for a Cm-Handle which are exposed to clients of the NCMP interface. \"; } container dmi-registry { list cm-handles { key \"id\"; leaf id { type string; } leaf dmi-service-name { type string; } leaf dmi-data-service-name { type string; } leaf dmi-model-service-name { type string; } list additional-properties { key \"name\"; leaf name { type string; } leaf value { type string; } } list public-additional-properties { key \"name\"; leaf name { type string; } leaf value { type string; } } } } } "|4899c384835ec48194ab5e3837549d32b844e02cfc81e9205234fa36354f3fe4 |
...
First copy the content from the CSV file above and create a YANG file locally with it with the format 'dmi-registry@*date-of-creationrevision*'.
Run the following command to insert a new yang resource into the yang_resource table with the checksum generated.
...
Once this is done, then add the change-set for yang resource you have created to load the data into the liquibase DB.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
- changeSet: author: cps label: dmi-registry-schema-preload id: 9.7 loadUpdateData: encoding: UTF-8 file: 'changelog/db/changes/data/dmi/yang_resource@2021-12-13.csv' onlyUpdate: 'false' primaryKey: 'id' quotchar: '"' separator: '|' tableName: 'yang_resource' columns: - column: header: name name: name type: STRING - column: header: content name: content type: STRING - column: header: checksum name: checksum type: STRING rollback: - sql: sql: delete from yang_resource where name = 'dmi-registry@2021-12-13.yang' |
...
Create a csv to define the data in the format of 'schema_set_yang_resources@*date-of-creationrevsision*'
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
schema_set_id|yang_resource_id (select id from schema_set where name='ncmp-dmi-registry-model')|(select id from yang_resource where name='dmi-registry@2021-12-13.yang') |
...