-
Notifications
You must be signed in to change notification settings - Fork 351
/
UpgradeCommand.php
86 lines (74 loc) · 2.86 KB
/
UpgradeCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Oro\Bundle\InstallerBundle\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class UpgradeCommand extends AbstractCommand
{
const COMMAND_NAME = 'oro:platform:upgrade20';
/**
* {@inheritdoc}
*/
public function configure()
{
$this
->setName(static::COMMAND_NAME)
->setDescription('Execute platform application upgrade commands. Upgrade from 1.10/1.12 to 2.0')
->addOption(
'force',
null,
InputOption::VALUE_NONE,
'Forces operation to be executed.'
)
->addOption(
'skip-assets',
null,
InputOption::VALUE_NONE,
'Skip UI related commands during update'
)
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->addOption(
'skip-translations',
null,
InputOption::VALUE_NONE,
'Determines whether translation data need to be loaded or not'
);
parent::configure();
}
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$force = $input->getOption('force');
if ($force) {
$commandExecutor = $this->getCommandExecutor($input, $output);
try {
$commandExecutor->runCommand('oro:platform:upgrade20:db-configs', ['--force' => true]);
$commandExecutor->runCommand(
'cache:warmup',
['--no-optional-warmers' => true, '--process-isolation' => true]
);
$updateParams = ['--process-isolation' => true];
foreach ($input->getOptions() as $key => $value) {
if ($value !== '' && $value !== null) {
$updateParams['--' . $key] = $value;
}
}
$commandExecutor->runCommand('oro:platform:update', $updateParams);
return 0;
} catch (\Exception $exception) {
return $commandExecutor->getLastCommandExitCode();
}
} else {
$output->writeln(
'<comment>ATTENTION</comment>: Database backup is highly recommended before executing this command.'
);
$output->writeln(' Please, remove application cache before run this command.');
$output->writeln('');
$output->writeln('To force execution run command with <info>--force</info> option:');
$output->writeln(sprintf(' <info>%s --force</info>', $this->getName()));
return 0;
}
}
}