Try to clear caches before updating (#522)

* Try to clear caches before updating

* Add clear-compiled to maintenance cache list

* Formatting
This commit is contained in:
Nabeel S 2020-01-30 14:59:48 -05:00 committed by GitHub
parent 3c1b433c29
commit 51b50972c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 0 deletions

View File

@ -2,7 +2,9 @@
namespace App\Contracts; namespace App\Contracts;
use App\Support\Database;
use DB; use DB;
use Illuminate\Support\Facades\Log;
/** /**
* Class Migration * Class Migration
@ -23,6 +25,22 @@ abstract class Migration extends \Illuminate\Database\Migrations\Migration
{ {
} }
/**
* Seed a YAML file into the database
*
* @param string $file Full path to yml file to seed
*/
public function seedFile($file): void
{
try {
$path = base_path($file);
Database::seed_from_yaml_file($path, false);
} catch (\Exception $e) {
Log::error('Unable to load '.$file.' file');
Log::error($e);
}
}
/** /**
* Add rows to a table * Add rows to a table
* *

View File

@ -42,6 +42,7 @@ class MaintenanceController extends Controller
$calls[] = 'config:cache'; $calls[] = 'config:cache';
$calls[] = 'cache:clear'; $calls[] = 'cache:clear';
$calls[] = 'route:cache'; $calls[] = 'route:cache';
$calls[] = 'clear-compiled';
} }
// If we want to clear only the views but keep everything else // If we want to clear only the views but keep everything else

View File

@ -3,6 +3,7 @@
namespace App\Services\Installer; namespace App\Services\Installer;
use App\Contracts\Service; use App\Contracts\Service;
use Illuminate\Support\Facades\Artisan;
use Nwidart\Modules\Facades\Module; use Nwidart\Modules\Facades\Module;
class InstallerService extends Service class InstallerService extends Service
@ -38,6 +39,23 @@ class InstallerService extends Service
return false; return false;
} }
/**
* Clear whatever caches we can by calling Artisan
*/
public function clearCaches(): void
{
$commands = [
'clear-compiled',
'cache:clear',
'route:clear',
'view:clear',
];
foreach ($commands as $cmd) {
Artisan::call($cmd);
}
}
/** /**
* Disable the installer and importer modules * Disable the installer and importer modules
*/ */

View File

@ -49,6 +49,8 @@ class UpdateController extends Controller
*/ */
public function step1(Request $request) public function step1(Request $request)
{ {
$this->installerSvc->clearCaches();
if ($this->installerSvc->isUpgradePending()) { if ($this->installerSvc->isUpgradePending()) {
Log::info('Upgrade is pending'); Log::info('Upgrade is pending');
} }