Skip to content

Commit

Permalink
Ignore upgrade error log, only attempt migration if classes exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Dec 8, 2014
1 parent 83c68cc commit 45f093f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
!/build/packages/.placeholder
/mockup
/upgrade
/upgrade_errors.txt
26 changes: 15 additions & 11 deletions app/bundles/CoreBundle/Command/ApplyUpdatesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

// Migrate the database to the current version
$command = $this->getApplication()->find('doctrine:migrations:migrate');
$input = new ArrayInput(array(
'command' => 'doctrine:migrations:migrate',
'--env' => $options['env'],
'--no-interaction' => true
));
$exitCode = $command->run($input, $output);

if ($exitCode !== 0) {
$output->writeln('<error>' . $translator->trans('mautic.core.update.error_performing_migration') . '</error>');
// Migrate the database to the current version if migrations exist
$iterator = new \FilesystemIterator($this->getContainer()->getParameter('kernel.root_dir') . '/migrations', \FilesystemIterator::SKIP_DOTS);

if (iterator_count($iterator)) {
$command = $this->getApplication()->find('doctrine:migrations:migrate');
$input = new ArrayInput(array(
'command' => 'doctrine:migrations:migrate',
'--env' => $options['env'],
'--no-interaction' => true
));
$exitCode = $command->run($input, $output);

if ($exitCode !== 0) {
$output->writeln('<error>' . $translator->trans('mautic.core.update.error_performing_migration') . '</error>');
}
}

// Clear the cached update data and the download package now that we've updated
Expand Down
17 changes: 11 additions & 6 deletions app/bundles/CoreBundle/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,18 @@ protected function updateDatabaseMigrationAction(Request $request)
{
$dataArray = array('success' => 0);
$translator = $this->factory->getTranslator();
$result = 0;

$env = $this->factory->getEnvironment();
$noDebug = ($env == 'prod') ? ' --no-debug' : '';
$input = new ArgvInput(array('console', 'doctrine:migrations:migrate', '--no-interaction --env=' . $env . $noDebug));
$application = new Application($this->get('kernel'));
$application->setAutoExit(false);
$result = $application->run($input);
$iterator = new \FilesystemIterator($this->container->getParameter('kernel.root_dir') . '/migrations', \FilesystemIterator::SKIP_DOTS);

if (iterator_count($iterator)) {
$env = $this->factory->getEnvironment();
$noDebug = ($env == 'prod') ? ' --no-debug' : '';
$input = new ArgvInput(array('console', 'doctrine:migrations:migrate', '--no-interaction --env=' . $env . $noDebug));
$application = new Application($this->get('kernel'));
$application->setAutoExit(false);
$result = $application->run($input);
}

if ($result !== 0) {
$dataArray['stepStatus'] = $translator->trans('mautic.core.update.step.failed');
Expand Down

0 comments on commit 45f093f

Please sign in to comment.