update = new Update(); } /** * Execute the console command. * * @return int */ public function handle() { define('WITH_LARAVEL', true); require ROOT_PATH . 'nexus/Database/helpers.php'; //Step 1 $step = $this->update->currentStep(); $log = "Step 1, Checking environment..."; $this->doLog($log); $requirements = $this->update->listRequirementTableRows(); $fails = $requirements['fails']; if (!empty($fails)) { foreach ($fails as $value) { $this->doLog("Error: " . nexus_json_encode($value), 'error'); } return 0; } $this->update->gotoStep(++$step); //Step 2 $log = "Step 2, get files, cli skip..."; $this->doLog($log); $this->update->gotoStep(++$step); //Step 3 $log = "Step 3, update .env, cli skip..."; $this->doLog($log); $this->update->gotoStep(++$step); //Step 4 $log = "Step 4, perform update..."; $this->doLog($log); $settingTableRows = $this->update->listSettingTableRows(); $settings = $settingTableRows['settings']; $symbolicLinks = $settingTableRows['symbolic_links']; $fails = $settingTableRows['fails']; $mysqlInfo = $this->update->getMysqlVersionInfo(); if (!empty($fails)) { foreach ($fails as $value) { $this->doLog("Error: " . nexus_json_encode($value), 'error'); } return 0; } if (!$mysqlInfo['match']) { $this->doLog("Error: MySQL version: {$mysqlInfo['version']} is too low, please use the newest version of 5.7 or above.", 'error'); return 0; } $this->doLog("going to createSymbolicLinks..."); $this->update->createSymbolicLinks($symbolicLinks); $this->doLog("createSymbolicLinks done!"); $this->doLog("going to saveSettings..."); $this->update->saveSettings($settings); $this->doLog("saveSettings done!"); $this->doLog("going to runExtraQueries..."); $this->update->runExtraQueries(); $this->doLog("runExtraQueries done!"); $this->doLog("going to runMigrate..."); $this->update->runMigrate(); $this->doLog("runMigrate done!"); $this->doLog("going to runExtraMigrate..."); $this->update->runExtraMigrate(); $this->doLog("runExtraMigrate done!"); $this->doLog("All done!"); return 0; } private function doLog($log, string $level = 'info') { $this->update->doLog($log); $this->{$level}(sprintf( '[%s] [%s] %s', date('Y-m-d H:i:s'), $this->update->currentStep(), $log )); } }