diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-08-15 12:39:19 +0100 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2024-08-26 08:21:39 +0000 |
commit | d802fd9a6c6aaffa330a30b68f7896ffebaa4fcd (patch) | |
tree | 823eb915f6322a38477d971273a0e43713ce0d06 /compose/config/db-migrator | |
parent | 10cf66cdd2cca12dad9f299714e6294ae35752a7 (diff) |
Change default database to PostgreSQL
Issue-ID: POLICY-5118
Change-Id: I22ece93aca3cbc5e406e4942ce5255a7b7b60761
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'compose/config/db-migrator')
-rwxr-xr-x | compose/config/db-migrator/init.sh | 19 | ||||
-rwxr-xr-x | compose/config/db-migrator/init_pg.sh | 23 |
2 files changed, 28 insertions, 14 deletions
diff --git a/compose/config/db-migrator/init.sh b/compose/config/db-migrator/init.sh index 047d947e..a8eb25a3 100755 --- a/compose/config/db-migrator/init.sh +++ b/compose/config/db-migrator/init.sh @@ -1,6 +1,6 @@ #!/bin/sh # ============LICENSE_START==================================================== -# Copyright (C) 2021 Nordix Foundation. +# Copyright (C) 2021, 2024 Nordix Foundation. # ============================================================================= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,14 +22,21 @@ export SQL_USER=${MYSQL_USER} export SQL_PASSWORD=${MYSQL_PASSWORD} export SCRIPT_DIRECTORY=sql -/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB} +for schema in ${SQL_DB}; do + echo "Initializing $schema..." + /opt/app/policy/bin/prepare_upgrade.sh ${schema} -/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report + /opt/app/policy/bin/db-migrator -s ${schema} -o report -/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o upgrade -rc=$? + /opt/app/policy/bin/db-migrator -s ${schema} -o upgrade + rc=$? -/opt/app/policy/bin/db-migrator -s ${SQL_DB} -o report + /opt/app/policy/bin/db-migrator -s ${schema} -o report + + if [ "$rc" != 0 ]; then + break + fi +done nc -l -p 6824 diff --git a/compose/config/db-migrator/init_pg.sh b/compose/config/db-migrator/init_pg.sh index 9b5f38e1..712d0d23 100755 --- a/compose/config/db-migrator/init_pg.sh +++ b/compose/config/db-migrator/init_pg.sh @@ -1,6 +1,6 @@ #!/bin/sh # ============LICENSE_START==================================================== -# Copyright (C) 2022 Nordix Foundation. +# Copyright (C) 2022, 2024 Nordix Foundation. # ============================================================================= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,18 +18,25 @@ # ============LICENSE_END====================================================== export POLICY_HOME=/opt/app/policy -export SQL_USER=${MYSQL_USER} -export SQL_PASSWORD=${MYSQL_PASSWORD} +export SQL_USER=${PGSQL_USER} +export SQL_PASSWORD=${PGSQL_PASSWORD} export SCRIPT_DIRECTORY=postgres -/opt/app/policy/bin/prepare_upgrade.sh ${SQL_DB} +for schema in ${SQL_DB}; do + echo "Initializing $schema..." + /opt/app/policy/bin/prepare_upgrade.sh ${schema} -/opt/app/policy/bin/db-migrator-pg -s ${SQL_DB} -o report + /opt/app/policy/bin/db-migrator-pg -s ${schema} -o report -/opt/app/policy/bin/db-migrator-pg -s ${SQL_DB} -o upgrade -rc=$? + /opt/app/policy/bin/db-migrator-pg -s ${schema} -o upgrade + rc=$? -/opt/app/policy/bin/db-migrator-pg -s ${SQL_DB} -o report + /opt/app/policy/bin/db-migrator-pg -s ${schema} -o report + + if [ "$rc" != 0 ]; then + break + fi +done nc -l -p 6824 |