I have a deployment script where I run migration commands:
# Clear cache
php bin/console cache:clear --env=prod
# Migrate database
php bin/console doctrine:migrations:diff --env=prod
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration --env=prod
With every deployment, where no entity change was made, the output consists of:
14:18:01 CRITICAL [console] Error thrown while running command "doctrine:migrations:diff --env=prod". Message: "No changes detected in your mapping information." ["exception" => Doctrine\Migrations\Generator\Exception\NoChangesDetected^ { …},"command" => "doctrine:migrations:diff --env=prod","message" => "No changes detected in your mapping information."]
In NoChangesDetected.php line 13:
No changes detected in your mapping information.
It is quite annoying and such "CRITICAL" error is not necessary. Only the exception message would be enough and informative enough.
Is there a way to only show the exception message "No changes detected in your mapping information." or, better, not execute the script in case there are no changes?
Versions in use:
# composer.json
"doctrine/doctrine-bundle": "1.12.*",
"doctrine/doctrine-migrations-bundle": "2.1.*",
"doctrine/migrations": "2.2.*",
"doctrine/orm": "2.6.*",
CodePudding user response:
If you run the command:
bin/console doctrine:migrations:diff --help
You can see that one of the options is:
--allow-empty-diff Do not throw an exception when no changes are detected.
Modify your script by adding the --allow-empty-diff
flag.