Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languageyml
titleLoad Data into Test Table
collapsetrue
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
languagebash
titleyang_resource@2021-12-13.csv
collapsetrue
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
languageyml
titleYang resource Change set example
collapsetrue
  - 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
languagebash
titleyang_resource@2021-12-13.csv
collapsetrue
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')

...