3 namespace Friendica\Console;
6 use Friendica\Core\Config\IConfiguration;
7 use Friendica\Core\L10n\L10n;
8 use Friendica\Core\Update;
11 * Performs database post updates
13 * License: AGPLv3 or later, same as Friendica
15 * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
16 * @author Hypolite Petovan <hypolite@mrpetovan.com>
18 class PostUpdate extends \Asika\SimpleConsole\Console
20 protected $helpOptions = ['h', 'help', '?'];
35 protected function getHelp()
38 console postupdate - Performs database post updates
40 bin/console postupdate [-h|--help|-?] [--reset <version>]
43 -h|--help|-? Show help information
44 --reset <version> Reset the post update version
49 public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null)
51 parent::__construct($argv);
53 $this->appMode = $appMode;
54 $this->config = $config;
58 protected function doExecute()
60 $a = \Friendica\DI::app();
62 if ($this->getOption($this->helpOptions)) {
63 $this->out($this->getHelp());
67 $reset_version = $this->getOption('reset');
68 if (is_bool($reset_version)) {
69 $this->out($this->getHelp());
71 } elseif ($reset_version) {
72 $this->config->set('system', 'post_update_version', $reset_version);
73 echo $this->l10n->t('Post update version number has been set to %s.', $reset_version) . "\n";
77 if ($this->appMode->isInstall()) {
78 throw new \RuntimeException('Database isn\'t ready or populated yet');
81 echo $this->l10n->t('Check for pending update actions.') . "\n";
82 Update::run($a->getBasePath(), true, false, true, false);
83 echo $this->l10n->t('Done.') . "\n";
85 echo $this->l10n->t('Execute pending post updates.') . "\n";
87 while (!\Friendica\Database\PostUpdate::update()) {
91 echo "\n" . $this->l10n->t('All pending post updates are done.') . "\n";