迁移 diff 命令在未检测到更改时抛出异常,而不仅仅是一条消息
Migrations diff command throws an exception instead of just a message when no changes detected
我有一个部署脚本,其中 运行 迁移命令:
# 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
在每次部署中,没有进行任何实体更改,输出包括:
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.
这很烦人,没有必要出现这样的“严重”错误。只有异常消息就足够了,信息量也足够了。
有没有办法只显示异常消息“在您的映射信息中未检测到任何变化。”或者,更好的是,如果没有更改,则不执行脚本?
正在使用的版本:
# composer.json
"doctrine/doctrine-bundle": "1.12.*",
"doctrine/doctrine-migrations-bundle": "2.1.*",
"doctrine/migrations": "2.2.*",
"doctrine/orm": "2.6.*",
如果您运行命令:
bin/console doctrine:migrations:diff --help
可以看到其中一个选项是:
--allow-empty-diff Do not throw an exception when no changes are detected.
通过添加 --allow-empty-diff
标志修改您的脚本。
我有一个部署脚本,其中 运行 迁移命令:
# 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
在每次部署中,没有进行任何实体更改,输出包括:
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.
这很烦人,没有必要出现这样的“严重”错误。只有异常消息就足够了,信息量也足够了。
有没有办法只显示异常消息“在您的映射信息中未检测到任何变化。”或者,更好的是,如果没有更改,则不执行脚本?
正在使用的版本:
# composer.json
"doctrine/doctrine-bundle": "1.12.*",
"doctrine/doctrine-migrations-bundle": "2.1.*",
"doctrine/migrations": "2.2.*",
"doctrine/orm": "2.6.*",
如果您运行命令:
bin/console doctrine:migrations:diff --help
可以看到其中一个选项是:
--allow-empty-diff Do not throw an exception when no changes are detected.
通过添加 --allow-empty-diff
标志修改您的脚本。