Versions Compared

Key

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

...

and run /opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade


Update config/sql directory:

01-honolulu.upgrade.sql 02-istanbul.downgrade.sql 02-istanbul.upgrade.sql downgrade upgrade

ls upgrade/
01-controlloop.upgrade.sql 02-jpatoscacapabilityassignment_occurrences.upgrade.sql
01-pdpgroup.upgrade.sql 02-jpatoscacapabilityassignment_properties.upgrade.sql
01-pdppolicystatus.upgrade.sql 02-jpatoscacapabilitytype_metadata.upgrade.sql
01-pdpstatistics.upgrade.sql 02-jpatoscacapabilitytype_properties.upgrade.sql
01-pdpsubgroup.upgrade.sql 02-jpatoscadatatype_constraints.upgrade.sql
01-pdp.upgrade.sql 02-jpatoscadatatype_metadata.upgrade.sql
01-sequence.upgrade.sql 02-jpatoscadatatype_properties.upgrade.sql
01-toscacapabilityassignments.upgrade.sql 02-jpatoscanodetemplate_metadata.upgrade.sql
01-toscacapabilityassignment.upgrade.sql 02-jpatoscanodetemplate_properties.upgrade.sql
01-toscacapabilitytypes.upgrade.sql 02-jpatoscanodetype_metadata.upgrade.sql
01-toscacapabilitytype.upgrade.sql 02-jpatoscanodetype_properties.upgrade.sql
01-toscadatatypes.upgrade.sql 02-jpatoscapolicy_metadata.upgrade.sql
01-toscadatatype.upgrade.sql 02-jpatoscapolicy_properties.upgrade.sql
01-toscanodetemplates.upgrade.sql 02-jpatoscapolicy_targets.upgrade.sql
01-toscanodetemplate.upgrade.sql 02-jpatoscapolicytype_metadata.upgrade.sql
01-toscanodetypes.upgrade.sql 02-jpatoscapolicytype_properties.upgrade.sql
01-toscanodetype.upgrade.sql 02-jpatoscapolicytype_targets.upgrade.sql
01-toscaparameter.upgrade.sql 02-jpatoscapolicytype_triggers.upgrade.sql
01-toscapolicies.upgrade.sql 02-jpatoscaproperty_constraints.upgrade.sql
01-toscapolicytypes.upgrade.sql 02-jpatoscaproperty_metadata.upgrade.sql
01-toscapolicytype.upgrade.sql 02-jpatoscarelationshiptype_metadata.upgrade.sql
01-toscapolicy.upgrade.sql 02-jpatoscarelationshiptype_properties.upgrade.sql
01-toscaproperty.upgrade.sql 02-jpatoscarequirement_metadata.upgrade.sql
01-toscarelationshiptypes.upgrade.sql 02-jpatoscarequirement_occurrences.upgrade.sql
01-toscarelationshiptype.upgrade.sql 02-jpatoscarequirement_properties.upgrade.sql
01-toscarequirements.upgrade.sql 02-jpatoscaservicetemplate_metadata.upgrade.sql
01-toscarequirement.upgrade.sql 02-jpatoscatopologytemplate_inputs.upgrade.sql
01-toscaservicetemplate.upgrade.sql 02-participantstatistics.upgrade.sql
01-toscatopologytemplate.upgrade.sql 02-participant.upgrade.sql
01-toscatrigger.upgrade.sql 02-pdpgroup_pdpsubgroup.upgrade.sql
02-clelementstatistics.upgrade.sql 02-pdpsubgroup_pdp.upgrade.sql
02-controlloop_controlloopelement.upgrade.sql 02-toscacapabilityassignments_toscacapabilityassignment.upgrade.sql
02-controlloopelement.upgrade.sql 02-toscacapabilitytypes_toscacapabilitytype.upgrade.sql
02-jpapdpgroup_properties.upgrade.sql 02-toscadatatypes_toscadatatype.upgrade.sql
02-jpapdpstatistics_enginestats.upgrade.sql 02-toscanodetemplates_toscanodetemplate.upgrade.sql
02-jpapdpsubgroup_policies.upgrade.sql 02-toscanodetypes_toscanodetype.upgrade.sql
02-jpapdpsubgroup_properties.upgrade.sql 02-toscapolicies_toscapolicy.upgrade.sql
02-jpapdpsubgroup_supportedpolicytypes.upgrade.sql 02-toscapolicytypes_toscapolicytype.upgrade.sql
02-jpapolicyaudit.upgrade.sql 02-toscarelationshiptypes_toscarelationshiptype.upgrade.sql
02-jpatoscacapabilityassignment_attributes.upgrade.sql 02-toscarequirements_toscarequirement.upgrade.sql
02-jpatoscacapabilityassignment_metadata.upgrade.sql


ls downgrade/
01-controlloop.downgrade.sql 02-jpatoscacapabilityassignment_occurrences.downgrade.sql
01-pdp.downgrade.sql 02-jpatoscacapabilityassignment_properties.downgrade.sql
01-pdpgroup.downgrade.sql 02-jpatoscacapabilitytype_metadata.downgrade.sql
01-pdppolicystatus.downgrade.sql 02-jpatoscacapabilitytype_properties.downgrade.sql
01-pdpstatistics.downgrade.sql 02-jpatoscadatatype_constraints.downgrade.sql
01-pdpsubgroup.downgrade.sql 02-jpatoscadatatype_metadata.downgrade.sql
01-sequence.downgrade.sql 02-jpatoscadatatype_properties.downgrade.sql
01-toscacapabilityassignment.downgrade.sql 02-jpatoscanodetemplate_metadata.downgrade.sql
01-toscacapabilityassignments.downgrade.sql 02-jpatoscanodetemplate_properties.downgrade.sql
01-toscacapabilitytype.downgrade.sql 02-jpatoscanodetype_metadata.downgrade.sql
01-toscacapabilitytypes.downgrade.sql 02-jpatoscanodetype_properties.downgrade.sql
01-toscadatatype.downgrade.sql 02-jpatoscapolicy_metadata.downgrade.sql
01-toscadatatypes.downgrade.sql 02-jpatoscapolicy_properties.downgrade.sql
01-toscanodetemplate.downgrade.sql 02-jpatoscapolicy_targets.downgrade.sql
01-toscanodetemplates.downgrade.sql 02-jpatoscapolicytype_metadata.downgrade.sql
01-toscanodetype.downgrade.sql 02-jpatoscapolicytype_properties.downgrade.sql
01-toscanodetypes.downgrade.sql 02-jpatoscapolicytype_targets.downgrade.sql
01-toscaparameter.downgrade.sql 02-jpatoscapolicytype_triggers.downgrade.sql
01-toscapolicies.downgrade.sql 02-jpatoscaproperty_constraints.downgrade.sql
01-toscapolicy.downgrade.sql 02-jpatoscaproperty_metadata.downgrade.sql
01-toscapolicytype.downgrade.sql 02-jpatoscarelationshiptype_metadata.downgrade.sql
01-toscapolicytypes.downgrade.sql 02-jpatoscarelationshiptype_properties.downgrade.sql
01-toscaproperty.downgrade.sql 02-jpatoscarequirement_metadata.downgrade.sql
01-toscarelationshiptype.downgrade.sql 02-jpatoscarequirement_occurrences.downgrade.sql
01-toscarelationshiptypes.downgrade.sql 02-jpatoscarequirement_properties.downgrade.sql
01-toscarequirement.downgrade.sql 02-jpatoscaservicetemplate_metadata.downgrade.sql
01-toscarequirements.downgrade.sql 02-jpatoscatopologytemplate_inputs.downgrade.sql
01-toscaservicetemplate.downgrade.sql 02-participant.downgrade.sql
01-toscatopologytemplate.downgrade.sql 02-participantstatistics.downgrade.sql
01-toscatrigger.downgrade.sql 02-pdpgroup_pdpsubgroup.downgrade.sql
02-clelementstatistics.downgrade.sql 02-pdpsubgroup_pdp.downgrade.sql
02-controlloop_controlloopelement.downgrade.sql 02-toscacapabilityassignments_toscacapabilityassignment.downgrade.sql
02-controlloopelement.downgrade.sql 02-toscacapabilitytypes_toscacapabilitytype.downgrade.sql
02-jpapdpgroup_properties.downgrade.sql 02-toscadatatypes_toscadatatype.downgrade.sql
02-jpapdpstatistics_enginestats.downgrade.sql 02-toscanodetemplates_toscanodetemplate.downgrade.sql
02-jpapdpsubgroup_policies.downgrade.sql 02-toscanodetypes_toscanodetype.downgrade.sql
02-jpapdpsubgroup_properties.downgrade.sql 02-toscapolicies_toscapolicy.downgrade.sql
02-jpapdpsubgroup_supportedpolicytypes.downgrade.sql 02-toscapolicytypes_toscapolicytype.downgrade.sql
02-jpapolicyaudit.downgrade.sql 02-toscarelationshiptypes_toscarelationshiptype.downgrade.sql
02-jpatoscacapabilityassignment_attributes.downgrade.sql 02-toscarequirements_toscarequirement.downgrade.sql
02-jpatoscacapabilityassignment_metadata.downgrade.sql


Update drools_policy_init.sh


Code Block
languagebash
titledrools_policy_init.sh
#!/bin/sh
# ============LICENSE_START====================================================
#  Copyright (C) 2021 Nordix Foundation.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END======================================================

export POLICY_HOME=/opt/app/policy
export SQL_USER=${MYSQL_USER}
export SQL_PASSWORD=${MYSQL_PASSWORD}
mkdir -p /opt/app/policy/etc/db/migration/${SQL_DB}/sql/
cp /home/policy/sql/*upgrade.sql /opt/app/policy/etc/db/migration/${SQL_DB}/sql/
cp -r /home/policy/sql/upgrade /opt/app/policy/etc/db/migration/${SQL_DB}/sql/

/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report

/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade

/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report

rm -rf /opt/app/policy/etc/db/migration/${SQL_DB}/sql/* >/dev/null 2>/dev/null
cp /home/policy/sql/*downgrade.sql /opt/app/policy/etc/db/migration/${SQL_DB}/sql/
cp -r /home/policy/sql/downgrade /opt/app/policy/etc/db/migration/${SQL_DB}/sql/

/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o downgrade -f 2 -t 1

/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report

nc -lk -p 6824

exit 0


drools-db-migration |
drools-db-migration | policyadmin: OK: upgrade (02)
drools-db-migration | name version
drools-db-migration | policyadmin 02
drools-db-migration | script operation success atTime
drools-db-migration | 01-honolulu.upgrade.sql upgrade 1 2021-06-30 10:48:15
drools-db-migration | 02-istanbul.upgrade.sql upgrade 1 2021-06-30 10:48:15
drools-db-migration | policyadmin: OK @ 02
drools-db-migration | downgrade: 2 -> 1
drools-db-migration |
drools-db-migration | > downgrade 02-istanbul.downgrade.sql
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `clelementstatistics`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `controlloop_controlloopelement`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `controlloopelement`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapdpgroup_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapdpstatistics_enginestats`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapdpsubgroup_policies`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapdpsubgroup_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapdpsubgroup_supportedpolicytypes`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpapolicyaudit`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilityassignment_attributes`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilityassignment_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilityassignment_occurrences`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilityassignment_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilitytype_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscacapabilitytype_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscadatatype_constraints`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscadatatype_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscadatatype_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscanodetemplate_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscanodetemplate_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscanodetype_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscanodetype_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicy_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicy_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicy_targets`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicytype_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicytype_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicytype_targets`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscapolicytype_triggers`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscaproperty_constraints`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscaproperty_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscarelationshiptype_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscarelationshiptype_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscarequirement_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscarequirement_occurrences`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscarequirement_properties`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscaservicetemplate_metadata`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `jpatoscatopologytemplate_inputs`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `participant`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `participantstatistics`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `pdpgroup_pdpsubgroup`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `pdpsubgroup_pdp`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscacapabilityassignments_toscacapabilityassignment`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscacapabilitytypes_toscacapabilitytype`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscadatatypes_toscadatatype`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscanodetemplates_toscanodetemplate`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscanodetypes_toscanodetype`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscapolicies_toscapolicy`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscapolicytypes_toscapolicytype`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscarelationshiptypes_toscarelationshiptype`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | --------------
drools-db-migration | DROP TABLE IF EXISTS `toscarequirements_toscarequirement`
drools-db-migration | --------------
drools-db-migration |
drools-db-migration | policyadmin: OK: downgrade (1)
drools-db-migration | name version
drools-db-migration | policyadmin 1
drools-db-migration | script operation success atTime
drools-db-migration | 01-honolulu.upgrade.sql upgrade 1 2021-06-30 10:48:15
drools-db-migration | 02-istanbul.upgrade.sql upgrade 1 2021-06-30 10:48:15
drools-db-migration | 02-istanbul.downgrade.sql downgrade 1 2021-06-30 10:48:16
drools-db-migration | policyadmin: downgrade available: 1 -> 0


MariaDB [(none)]> use migration;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [migration]> select * from policyadmin_history;
+---------------------------+-----------+---------+---------------------+
| script | operation | success | atTime |
+---------------------------+-----------+---------+---------------------+
| 01-honolulu.upgrade.sql | upgrade | 1 | 2021-06-30 10:48:15 |
| 02-istanbul.downgrade.sql | downgrade | 1 | 2021-06-30 10:48:16 |
| 02-istanbul.upgrade.sql | upgrade | 1 | 2021-06-30 10:48:15 |
+---------------------------+-----------+---------+---------------------+
3 rows in set (0.000 sec)

MariaDB [migration]> select * from metadata_versions;
+-------------+---------+
| name | version |
+-------------+---------+
| policyadmin | 1 |
+-------------+---------+
1 row in set (0.001 sec)


https://docs.onap.org/projects/onap-policy-parent/en/guilin/drools/pdpdEngine.html#data-migration