diff --git a/CHANGELOG.md b/CHANGELOG.md index cf8fcfe7..8625ca95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Added - Support to define remote shell path via host-config [#1708] [#1709] [#1709] - Added `horizon:terminate` to the Laravel recipe +- Added `migrations_config` option to the Symfony recipes to specify Doctrine migration configuration to use ### Changed - Laravel recipe should not run `artisan:cache:clear` in `deploy` task diff --git a/recipe/symfony.php b/recipe/symfony.php index 0659c9e2..29539ec1 100644 --- a/recipe/symfony.php +++ b/recipe/symfony.php @@ -57,6 +57,9 @@ set('console_options', function () { return get('symfony_env') !== 'prod' ? $options : sprintf('%s --no-debug', $options); }); +// Migrations configuration file +set('migrations_config', ''); + /** * Create cache dir @@ -124,7 +127,12 @@ task('deploy:cache:warmup', function () { * Migrate database */ task('database:migrate', function () { - run('{{bin/php}} {{bin/console}} doctrine:migrations:migrate {{console_options}} --allow-no-migration'); + $options = '{{console_options}} --allow-no-migration'; + if (get('migrations_config') !== '') { + $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); + } + + run(sprintf('{{bin/php}} {{bin/console}} doctrine:migrations:migrate %s', $options)); })->desc('Migrate database'); diff --git a/recipe/symfony4.php b/recipe/symfony4.php index c13be535..a4e4df9a 100644 --- a/recipe/symfony4.php +++ b/recipe/symfony4.php @@ -12,6 +12,7 @@ require_once 'recipe/common.php'; set('shared_dirs', ['var/log', 'var/sessions']); set('shared_files', ['.env']); set('writable_dirs', ['var']); +set('migrations_config', ''); set('bin/console', function () { return parse('{{bin/php}} {{release_path}}/bin/console --no-interaction'); @@ -19,7 +20,12 @@ set('bin/console', function () { desc('Migrate database'); task('database:migrate', function () { - run('{{bin/console}} doctrine:migrations:migrate --allow-no-migration'); + $options = '--allow-no-migration'; + if (get('migrations_config') !== '') { + $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); + } + + run(sprintf('{{bin/console}} doctrine:migrations:migrate %s', $options)); }); desc('Clear cache');