Skip to content

Commit

Permalink
Enhance CI results when updated DB is not consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Nov 16, 2023
1 parent d03e609 commit de93a65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/actions/test_update-from-9.5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/test_update-from-older-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/Console/Database/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
[
'<comment>' . __('The database schema integrity check has been skipped.') . '</comment>',
'<comment>' . 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'
) . '</comment>'
],
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.
Expand Down

0 comments on commit de93a65

Please sign in to comment.