Move the MigrationService to the main package
This commit is contained in:
parent
905be6ffc3
commit
29a578ea6a
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Interfaces\Migration;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
@ -9,7 +10,7 @@ class CreateSettingsTable extends Migration
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->migrationSvc = new \Modules\Installer\Services\MigrationService();
|
||||
$this->migrationSvc = new MigrationService();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +38,7 @@ class CreateSettingsTable extends Migration
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$this->migrationSvc->updateAllSettings();
|
||||
$this->migrationSvc->syncAllSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Installer\Services;
|
||||
namespace App\Services\Installer;
|
||||
|
||||
use App\Interfaces\Service;
|
||||
use App\Models\Setting;
|
||||
@ -26,14 +26,18 @@ class MigrationService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all of the settings and sync them with the settings.yml file
|
||||
* Syncronize all of the seed files, run this after the
|
||||
*/
|
||||
public function updateAllSettings(): void
|
||||
public function syncAllSeeds(): void
|
||||
{
|
||||
$this->syncAllSettings();
|
||||
}
|
||||
|
||||
public function syncAllSettings(): void {
|
||||
$data = file_get_contents(database_path('/seeds/settings.yml'));
|
||||
$yml = Yaml::parse($data);
|
||||
foreach ($yml as $setting) {
|
||||
if ($setting['key'] === '') {
|
||||
if (\trim($setting['key']) === '') {
|
||||
continue;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use App\Interfaces\Controller;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Services\AnalyticsService;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Countries;
|
||||
use Illuminate\Database\QueryException;
|
||||
@ -16,7 +17,6 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Log;
|
||||
use Modules\Installer\Services\ConfigService;
|
||||
use Modules\Installer\Services\DatabaseService;
|
||||
use Modules\Installer\Services\MigrationService;
|
||||
use Modules\Installer\Services\RequirementsService;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
|
||||
|
@ -3,9 +3,10 @@
|
||||
namespace Modules\Installer\Http\Controllers;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Modules\Installer\Services\MigrationService;
|
||||
|
||||
|
||||
/**
|
||||
* Class UpdaterController
|
||||
@ -36,6 +37,10 @@ class UpdaterController extends Controller
|
||||
/**
|
||||
* Step 1. Check if there's an update available. Check if there
|
||||
* are any unrun migrations
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function step1(Request $request)
|
||||
{
|
||||
@ -49,22 +54,23 @@ class UpdaterController extends Controller
|
||||
|
||||
/**
|
||||
* Step 2 Run all of the migrations
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function run_migrations(Request $request)
|
||||
{
|
||||
Log::info('Update: run_migrations', $request->post());
|
||||
|
||||
// Resync all of the settings
|
||||
$this->migrationSvc->updateAllSettings();
|
||||
|
||||
$migrations = $this->migrationSvc->migrationsAvailable();
|
||||
if(\count($migrations) === 0) {
|
||||
$this->migrationSvc->syncAllSeeds();
|
||||
return view('installer::update/steps/step3-update-complete');
|
||||
}
|
||||
|
||||
$output = $this->migrationSvc->runAllMigrations();
|
||||
$this->migrationSvc->syncAllSeeds();
|
||||
|
||||
return view('installer::update/steps/step2-migrations-done', [
|
||||
'console_output' => $output,
|
||||
@ -73,7 +79,9 @@ class UpdaterController extends Controller
|
||||
|
||||
/**
|
||||
* Final step
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function complete(Request $request)
|
||||
|
Loading…
Reference in New Issue
Block a user