deployer/recipe/symfony4.php
bonswouar f7fb577b34
[#2207] Symfony change dir to execute DoctrineMigrations (#2208)
Co-authored-by: bonswouar <contact@florianmessmer.com>
2020-10-17 11:07:22 +03:00

49 lines
1.2 KiB
PHP

<?php
namespace Deployer;
require_once __DIR__ . '/common.php';
set('shared_dirs', ['var/log', 'var/sessions']);
set('shared_files', ['.env.local.php', '.env.local']);
set('writable_dirs', ['var']);
set('migrations_config', '');
set('bin/console', function () {
return parse('{{release_path}}/bin/console');
});
set('console_options', function () {
return '--no-interaction';
});
desc('Migrate database');
task('database:migrate', function () {
$options = '--allow-no-migration';
if (get('migrations_config') !== '') {
$options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options);
}
run(sprintf('cd {{release_path}} && {{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options));
});
desc('Clear cache');
task('deploy:cache:clear', function () {
run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup');
});
desc('Warm up cache');
task('deploy:cache:warmup', function () {
run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}');
});
desc('Deploy project');
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'deploy:cache:clear',
'deploy:cache:warmup',
'deploy:publish',
]);
after('deploy', 'success');