Versions Compared

Key

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

...

Proposed Liquibase changes

Code Block
languageyml

databaseChangeLog:

  - changeSet:
      id: 19-1
      author: cps
      changes:
        - dropIndex:
            indexName: FKI_FRAGMENT_DATASPACE_ID_FK
            tableName: fragment
      rollback:
        - createIndex:
            columns:
              - column:
                  name: dataspace_id
            indexName: FKI_FRAGMENT_DATASPACE_ID_FK
            tableName: fragment

  - changeSet:
      id: 19-2
      author: cps
      changes:
        - dropUniqueConstraint:
            constraintName: fragment_dataspace_id_anchor_id_xpath_key
            tableName: fragment
        - addUniqueConstraint:
            columnNames: anchor_id, xpath
            constraintName: fragment_anchor_id_xpath_key
            tableName: fragment
      rollback:
        - dropUniqueConstraint:
            constraintName: fragment_anchor_id_xpath_key
            tableName: fragment
        - addUniqueConstraint:
            columnNames: dataspace_id, anchor_id, xpath
            constraintName: fragment_dataspace_id_anchor_id_xpath_key
            tableName: fragment

  - changeSet:
      id: 19-3
      author: cps
      changes:
        - dropForeignKeyConstraint:
            baseTableName: fragment
            constraintName: fragment_dataspace_id_fkey
      rollback:
        - addForeignKeyConstraint:
            baseColumnNames: dataspace_id
            baseTableName: fragment
            constraintName: fragment_dataspace_id_fkey
            deferrable: false
            initiallyDeferred: false
            onDelete: NO ACTION
            onUpdate: NO ACTION
            referencedColumnNames: id
            referencedTableName: dataspace
            validate: true

  - changeSet:
      id: 19-4
      author: cps
      changes:
        - dropColumn:
            columnName: dataspace_id
            tableName: fragment
      rollback:
        - addColumn:
            tableName: fragment
            columns:
              - column:
                  name: dataspace_id
                  type: INTEGER
        - sqlFile:
            path: changelog/db/changes/19-repopulate-dataspace-id-for-rollback.sql
        - addNotNullConstraint:
            tableName: fragment
            columnName: dataspace_id
            columnDataType: INTEGER

As part of the rollback procedure, the removed column must be re-populated with data. The following SQL is used to do this:

Code Block
languagesql
UPDATE
    fragment AS f
SET
    dataspace_id = a.dataspace_id
FROM
    anchor AS a
WHERE
    f.anchor_id = a.id;

Results

Table description before update, after update, and after rollback

...

Fragment table before update, after update, and after rollback

Before update
idxpathattributesanchor_idparent_iddataspace_idschema_node_id
1/cps-ran-schema{}1null1null
2/cps-ran-schema/NearRTRIC[@idNearRTRIC="11"]{"idNearRTRIC": "11"}111null
137/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15549"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15549}11361null
139/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15360"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15360}11381null
141/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15361"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15361}11401null
144/dmi-registry{}2null2null
145/dmi-registry/cm-handles[@id='336a9e2779b64a1cac04fee3208a1c76']{"id": "336a9e2779b64a1cac04fee3208a1c76", "dmi-service-name": "http://ncmp-dmi-plugin-stub:8080", "dmi-data-service-name": "", "dmi-model-service-name": ""}21442null
After update
idxpathattributesanchor_idparent_idschema_node_id
1/cps-ran-schema{}1nullnull
2/cps-ran-schema/NearRTRIC[@idNearRTRIC="11"]{"idNearRTRIC": "11"}11null
137/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15549"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15549}1136null
139/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15360"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15360}1138null
141/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15361"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15361}1140null
144/dmi-registry{}2nullnull
145/dmi-registry/cm-handles[@id='48d42e05942b457dafdfa24195fdb092']{"id": "48d42e05942b457dafdfa24195fdb092", "dmi-service-name": "http://ncmp-dmi-plugin-stub:8080", "dmi-data-service-name": "", "dmi-model-service-name": ""}2144null
After rollback
idxpathattributesanchor_idparent_idschema_node_iddataspace_id
1/cps-ran-schema{}1nullnull1
2/cps-ran-schema/NearRTRIC[@idNearRTRIC="11"]{"idNearRTRIC": "11"}11null1
137/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15549"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15549}1136null1
139/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15360"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15360}1138null1
141/cps-ran-schema/NearRTRIC[@idNearRTRIC="22"]/GNBDUFunction[@idGNBDUFunction="6"]/NRCellDU[@idNRCellDU="15361"]/attributes{"nRPCI": 12, "nRTAC": 310, "cellLocalId": 15361}1140null1
144/dmi-registry{}2nullnull2
145/dmi-registry/cm-handles[@id='48d42e05942b457dafdfa24195fdb092']{"id": "48d42e05942b457dafdfa24195fdb092", "dmi-service-name": "http://ncmp-dmi-plugin-stub:8080", "dmi-data-service-name": "", "dmi-model-service-name": ""}2144null2