I'm using Deployer to deploy my Symfony application to production. All is working fine, however, my deploy.php file has the command for database migrations:
/**
* Run a diff to generate migrations,
*/
task('database:diff', function () {
run('{{bin/php}} {{release_path}}/' . trim(get('bin_dir'), '/') . '/console doctrine:migrations:diff --env={{env}} --no-debug --no-interaction');
})->desc('Generate migrations database');
...
after('deploy:symlink','database:diff');
after('database:diff','database:migrate');
But if there are no changes to the database then this step causes an error.
Error message:
[RuntimeException]
[Doctrine\DBAL\Migrations\MigrationException]
Could not find any migrations to execute.
I'm looking for some code that can check for any database change and only conditionally run the migrations tasks if there are changes.