3 namespace Friendica\Core\Console;
5 use Friendica\Core\Config;
6 use Friendica\Core\L10n;
7 use Friendica\Core\Update;
10 * Performs database post updates
12 * License: AGPLv3 or later, same as Friendica
14 * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
15 * @author Hypolite Petovan <hypolite@mrpetovan.com>
17 class PostUpdate extends \Asika\SimpleConsole\Console
19 protected $helpOptions = ['h', 'help', '?'];
21 protected function getHelp()
24 console postupdate - Performs database post updates
26 bin/console postupdate [-h|--help|-?] [--reset <version>]
29 -h|--help|-? Show help information
30 --reset <version> Reset the post update version
35 protected function doExecute()
37 $a = \Friendica\BaseObject::getApp();
39 if ($this->getOption($this->helpOptions)) {
40 $this->out($this->getHelp());
44 $reset_version = $this->getOption('reset');
45 if (is_bool($reset_version)) {
46 $this->out($this->getHelp());
48 } elseif ($reset_version) {
49 Config::set('system', 'post_update_version', $reset_version);
50 echo L10n::t('Post update version number has been set to %s.', $reset_version) . "\n";
54 if ($a->getMode()->isInstall()) {
55 throw new \RuntimeException('Database isn\'t ready or populated yet');
58 echo L10n::t('Check for pending update actions.') . "\n";
59 Update::run($a->getBasePath(), true, false,true, false);
60 echo L10n::t('Done.') . "\n";
62 echo L10n::t('Execute pending post updates.') . "\n";
64 while (!\Friendica\Database\PostUpdate::update()) {
68 echo "\n" . L10n::t('All pending post updates are done.') . "\n";