X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=docs%2Fsystem-attributes%2Fpolicy-db-migrator.rst;h=2fa94874b9f1025fa2c54a55c3fa81a7bd61e84e;hb=afc87ad6f24d39a6b62ce4a309e9433f84abc84b;hp=b828121cbd3e64014d2581912c9eadc6348a6779;hpb=46279f0b5e961d4c935eaf961120e880ec01c1d4;p=policy%2Fparent.git diff --git a/docs/system-attributes/policy-db-migrator.rst b/docs/system-attributes/policy-db-migrator.rst index b828121c..2fa94874 100644 --- a/docs/system-attributes/policy-db-migrator.rst +++ b/docs/system-attributes/policy-db-migrator.rst @@ -23,6 +23,7 @@ Policy DB Migrator is run as a docker container and consists of the following sc prepare_upgrade.sh prepare_downgrade.sh db-migrator + db-migrator-pg ``prepare_upgrade.sh`` is included as part of the docker image and is used @@ -33,9 +34,10 @@ This script takes one parameter: . to copy the downgrade sql files to the run directory. This script takes one parameter: . -``db-migrator`` is included as part of the docker image and is used -to run either the upgrade or downgrade operation depending on user requirements. -This script can take up to four parameters: +``db-migrator`` and ``db-migrator-pg`` are included as part of the docker image +and are used to run either the upgrade or downgrade operation for MariaDB or +PostgresSQL depending on user requirements. +These script can take up to four parameters: .. list-table:: :widths: 20 20 20 @@ -79,6 +81,32 @@ to run and connect to the database. - policy_user * - POLICY_HOME - /opt/app/policy + * - SCRIPT_DIRECTORY + - sql + +The following environment variables need to be set to enable ``db-migrator-pg`` +to run and connect to the database. + +.. list-table:: + :widths: 20 20 + :header-rows: 1 + + * - Name + - Value (example) + * - SQL_HOST + - postgres + * - SQL_DB + - policyadmin + * - SQL_USER + - policy_user + * - SQL_PASSWORD + - policy_user + * - POLICY_HOME + - /opt/app/policy + * - SCRIPT_DIRECTORY + - postgres + * - PGPASSWORD + - ${SQL_PASSWORD} Prepare Upgrade =============== @@ -89,7 +117,7 @@ Prior to upgrading the following script is run: /opt/app/policy/bin/prepare_upgrade.sh -This will copy the upgrade files from ``/home/policy/sql`` to ``$POLICY_HOME/etc/db/migration//sql/`` +This will copy the upgrade files from ``/home/policy/${SCRIPT_DIRECTORY}`` to ``$POLICY_HOME/etc/db/migration//${SCRIPT_DIRECTORY}/`` Each individual sql file that makes up that release will be run as part of the upgrade. @@ -102,7 +130,7 @@ Prior to downgrading the following script is run: /opt/app/policy/bin/prepare_downgrade.sh -This will copy the downgrade files from ``/home/policy/sql`` to ``$POLICY_HOME/etc/db/migration//sql/`` +This will copy the downgrade files from ``/home/policy/${SCRIPT_DIRECTORY}`` to ``$POLICY_HOME/etc/db/migration//${SCRIPT_DIRECTORY}/`` Each individual sql file that makes up that release will be run as part of the downgrade. @@ -113,6 +141,12 @@ Upgrade /opt/app/policy/bin/db-migrator -s -o upgrade -f 0800 -t 0900 +OR + +.. code:: + + /opt/app/policy/bin/db-migrator-pg -s -o upgrade -f 0800 -t 0900 + If the ``-f`` and ``-t`` flags are not specified, the script will attempt to run all available sql files greater than the current version. @@ -125,6 +159,12 @@ Downgrade /opt/app/policy/bin/db-migrator -s -o downgrade -f 0900 -t 0800 +OR + +.. code:: + + /opt/app/policy/bin/db-migrator-pg -s -o downgrade -f 0900 -t 0800 + If the ``-f`` and ``-t`` flags are not specified, the script will attempt to run all available sql files less than the current version. @@ -133,13 +173,17 @@ The script will return either 1 or 0 depending on successful completion. Logging ======= -After every upgrade/downgrade ``db-migrator`` runs the report operation to show the -contents of the db-migrator log table. +After every upgrade/downgrade ``db-migrator`` or ``db-migrator-pg`` runs the report operation +to show the contents of the db-migrator log table. .. code:: /opt/app/policy/bin/db-migrator -s -o report +.. code:: + + /opt/app/policy/bin/db-migrator-pg -s -o report + Console output will also show the sql script command as in the example below: .. code:: @@ -227,6 +271,14 @@ It is setup to run an upgrade by default. /opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report exit $rc +.. code:: + + /opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB} + /opt/app/policy/bin/db-migrator-pg -s ${SQL_DB} -o upgrade + rc=$? + /opt/app/policy/bin/db-migrator-pg -s ${SQL_DB} -o report + exit $rc + The following table describes what each line does: .. list-table::