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:
parent
3c1b433c29
commit
51b50972c8
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Support\Database;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -42,6 +42,7 @@ class MaintenanceController extends Controller
|
||||
$calls[] = 'config:cache';
|
||||
$calls[] = 'cache:clear';
|
||||
$calls[] = 'route:cache';
|
||||
$calls[] = 'clear-compiled';
|
||||
}
|
||||
|
||||
// If we want to clear only the views but keep everything else
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Services\Installer;
|
||||
|
||||
use App\Contracts\Service;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
|
||||
class InstallerService extends Service
|
||||
@ -38,6 +39,23 @@ class InstallerService extends Service
|
||||
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
|
||||
*/
|
||||
|
@ -49,6 +49,8 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function step1(Request $request)
|
||||
{
|
||||
$this->installerSvc->clearCaches();
|
||||
|
||||
if ($this->installerSvc->isUpgradePending()) {
|
||||
Log::info('Upgrade is pending');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user