-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update both main and reportdb databases, using only upgrade script fo…
…r the new version
- Loading branch information
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
src_dir=$(cd $(dirname "$0")/../.. && pwd -P) | ||
|
||
sudo -i podman exec uyuni-server-all-in-one-test bash -c "/usr/lib/susemanager/bin/mgr-setup -l /var/log/susemanager_setup.log -s" | ||
sudo -i podman exec uyuni-server-all-in-one-test bash -c "/usr/bin/spacewalk-schema-upgrade -y" | ||
# Make sure latest sql migration scripts have been executed | ||
sudo -i podman exec uyuni-server-all-in-one-test bash -c "/testsuite/podman_runner/run_db_migrations.sh" | ||
|
||
# Make sure latest sql migration scripts have been executed for both the main and the reporting database | ||
available_schemas=("spacewalk" "reportdb") | ||
for schema in ${available_schemas[@]}; do | ||
specfile=$(find ${src_dir}/schema/${schema}/ -name *.spec) | ||
# Use Perl extended regexp and look-around assertions to extract only the values from the spec properties | ||
schema_name=$(grep -oP "Name:\s+\K(.*)$" ${specfile}) | ||
schema_version=$(grep -oP "Version:\s+\K(.*)$" ${specfile}) | ||
|
||
sudo -i podman exec uyuni-server-all-in-one-test bash -c "/testsuite/podman_runner/run_db_migrations.sh ${schema_name} ${schema_version}" | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
#!/bin/bash -e | ||
for i in $(ls /etc/sysconfig/rhn/schema-upgrade/ | tail -n1);do | ||
for j in $(ls /etc/sysconfig/rhn/schema-upgrade/$i);do | ||
echo $i;spacewalk-sql /etc/sysconfig/rhn/schema-upgrade/$i/$j; | ||
|
||
if [ $# -ne 2 ]; | ||
then | ||
echo "Usage: $0 <schema_name> <schema_version>" | ||
echo "where" | ||
echo " schema_name name of the schema to update (susemanager-schema or uyuni-reportdb-schema)" | ||
echo " schema_version version of the schema currently installed" | ||
exit 1 | ||
fi | ||
|
||
if [[ "$1" == "susemanager-schema" ]]; | ||
then | ||
upgrade_dir="/etc/sysconfig/rhn/schema-upgrade/" | ||
additional_params="" | ||
elif [[ "$1" == "uyuni-reportdb-schema" ]]; | ||
then | ||
upgrade_dir="/etc/sysconfig/rhn/reportdb-schema-upgrade/" | ||
additional_params="--reportdb" | ||
else | ||
echo "Unknown schema $1. Use either susemanager-schema or uyuni-reportdb-schema." | ||
exit 1 | ||
fi | ||
|
||
for i in $(find ${upgrade_dir} -name "$1-$2-to-*"); do | ||
echo $(basename $i) | ||
for j in $(find $i -name *.sql); do | ||
echo -e "\t$(basename $j)"; spacewalk-sql ${additional_params} $j | sed 's/^/\t\t/'; | ||
done; | ||
done | ||
|