diff --git a/app/Contracts/Migration.php b/app/Contracts/Migration.php index c06efea7d..5192b8fbc 100644 --- a/app/Contracts/Migration.php +++ b/app/Contracts/Migration.php @@ -2,7 +2,9 @@ namespace App\Contracts; +use App\Support\Database; use DB; +use Illuminate\Support\Facades\Log; /** * Class Migration @@ -23,6 +25,22 @@ public function down() { } + /** + * 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 * diff --git a/app/Http/Controllers/Admin/MaintenanceController.php b/app/Http/Controllers/Admin/MaintenanceController.php index 8f1470e8f..92264e2da 100644 --- a/app/Http/Controllers/Admin/MaintenanceController.php +++ b/app/Http/Controllers/Admin/MaintenanceController.php @@ -42,6 +42,7 @@ public function cache(Request $request) $calls[] = 'config:cache'; $calls[] = 'cache:clear'; $calls[] = 'route:cache'; + $calls[] = 'clear-compiled'; } // If we want to clear only the views but keep everything else diff --git a/app/Services/Installer/InstallerService.php b/app/Services/Installer/InstallerService.php index f0ccdb355..dde48a75a 100644 --- a/app/Services/Installer/InstallerService.php +++ b/app/Services/Installer/InstallerService.php @@ -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 @@ public function isUpgradePending(): bool 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 */ diff --git a/modules/Updater/Http/Controllers/UpdateController.php b/modules/Updater/Http/Controllers/UpdateController.php index 406f96eca..ea205d576 100644 --- a/modules/Updater/Http/Controllers/UpdateController.php +++ b/modules/Updater/Http/Controllers/UpdateController.php @@ -49,6 +49,8 @@ public function index() */ public function step1(Request $request) { + $this->installerSvc->clearCaches(); + if ($this->installerSvc->isUpgradePending()) { Log::info('Upgrade is pending'); }