X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=docs%2Fsystem-attributes%2Fpolicy-db-migrator.rst;h=840137e9e995d281af0c1b5ad5aa966fbca6353d;hb=688a2dd3a681c28ac48ad737316c2dc1dff08526;hp=b828121cbd3e64014d2581912c9eadc6348a6779;hpb=f41b4025e6da865556db59d333669f8b7b35d602;p=policy%2Fparent.git diff --git a/docs/system-attributes/policy-db-migrator.rst b/docs/system-attributes/policy-db-migrator.rst index b828121c..840137e9 100644 --- a/docs/system-attributes/policy-db-migrator.rst +++ b/docs/system-attributes/policy-db-migrator.rst @@ -2,6 +2,8 @@ .. 4.0 International License. .. http://creativecommons.org/licenses/by/4.0 +.. _policy-db-migrator-label: + Using Policy DB Migrator ######################## @@ -23,6 +25,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 +36,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 +83,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 +119,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 +132,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 +143,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 +161,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 +175,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 +273,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::