From de93a65c2b2718287d38c75113e8c98b9f9428e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 15 Nov 2023 11:59:29 +0100 Subject: [PATCH] Enhance CI results when updated DB is not consistent --- .github/actions/test_update-from-9.5.sh | 4 ++-- .github/actions/test_update-from-older-version.sh | 4 ++-- src/Console/Database/UpdateCommand.php | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/actions/test_update-from-9.5.sh b/.github/actions/test_update-from-9.5.sh index 4105c90d854..2da31db0bac 100755 --- a/.github/actions/test_update-from-9.5.sh +++ b/.github/actions/test_update-from-9.5.sh @@ -11,12 +11,12 @@ bin/console database:configure \ # Execute update ## First run should do the migration (with no warnings/errors). -bin/console database:update --config-dir=./tests/config --ansi --no-interaction --allow-unstable | tee $LOG_FILE +bin/console database:update --config-dir=./tests/config --skip-db-checks --ansi --no-interaction --allow-unstable | tee $LOG_FILE if [[ -n $(grep "Error\|Warning\|No migration needed." $LOG_FILE) ]]; then echo "bin/console database:update command FAILED" && exit 1; fi ## Second run should do nothing. -bin/console database:update --config-dir=./tests/config --ansi --no-interaction --allow-unstable | tee $LOG_FILE +bin/console database:update --config-dir=./tests/config --skip-db-checks --ansi --no-interaction --allow-unstable | tee $LOG_FILE if [[ -z $(grep "No migration needed." $LOG_FILE) ]]; then echo "bin/console database:update command FAILED" && exit 1; fi diff --git a/.github/actions/test_update-from-older-version.sh b/.github/actions/test_update-from-older-version.sh index 0450c1e99fa..02583d8d6b0 100755 --- a/.github/actions/test_update-from-older-version.sh +++ b/.github/actions/test_update-from-older-version.sh @@ -11,12 +11,12 @@ bin/console database:configure \ # Execute update ## First run should do the migration (with no warnings/errors). -bin/console database:update --config-dir=./tests/config --ansi --no-interaction --allow-unstable | tee $LOG_FILE +bin/console database:update --config-dir=./tests/config --skip-db-checks --ansi --no-interaction --allow-unstable | tee $LOG_FILE if [[ -n $(grep "Error\|Warning\|No migration needed." $LOG_FILE) ]]; then echo "bin/console database:update command FAILED" && exit 1; fi ## Second run should do nothing. -bin/console database:update --config-dir=./tests/config --ansi --no-interaction --allow-unstable | tee $LOG_FILE +bin/console database:update --config-dir=./tests/config --skip-db-checks --ansi --no-interaction --allow-unstable | tee $LOG_FILE if [[ -z $(grep "No migration needed." $LOG_FILE) ]]; then echo "bin/console database:update command FAILED" && exit 1; fi diff --git a/src/Console/Database/UpdateCommand.php b/src/Console/Database/UpdateCommand.php index cb26071bfae..290ffe9c783 100644 --- a/src/Console/Database/UpdateCommand.php +++ b/src/Console/Database/UpdateCommand.php @@ -105,7 +105,7 @@ protected function configure() '--skip-db-checks', 's', InputOption::VALUE_NONE, - __('Do not check database schema integrity before performing the update') + __('Do not check database schema integrity before and after performing the update') ); $this->addOption( @@ -221,7 +221,18 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->handTelemetryActivation($input, $output); - if (!$update->isUpdatedSchemaConsistent()) { + if ($this->input->getOption('skip-db-checks')) { + $this->output->writeln( + [ + '' . __('The database schema integrity check has been skipped.') . '', + '' . sprintf( + __('It is recommended to run the "%s" command to validate that the database schema is consistent with the current GLPI version.'), + 'php bin/console database:check_schema_integrity' + ) . '' + ], + OutputInterface::VERBOSITY_QUIET + ); + } elseif (!$update->isUpdatedSchemaConsistent()) { // Exit with an error if database schema is not consistent. // Keep this code at end of command to ensure that the whole migration is still executed. // Many old GLPI instances will likely have differences, and people will have to fix them manually.