Fix migrations when table prefix is involved #442 (#555)

* Fix migrations when table prefix is involved #442

* Formatting
This commit is contained in:
Nabeel S 2020-02-18 08:23:32 -05:00 committed by GitHub
parent 2d36376e29
commit 8300a69ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 30 deletions

View File

@ -6,6 +6,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Laracasts\Flash\Flash;
/** /**
* Class Controller * Class Controller
@ -26,7 +27,7 @@ abstract class Controller extends \Illuminate\Routing\Controller
*/ */
public function flashError($message, $route) public function flashError($message, $route)
{ {
flash()->error($message); Flash::error($message);
return redirect(route($route))->withInput(); return redirect(route($route))->withInput();
} }

View File

@ -2,6 +2,7 @@
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class AddReadonlyToRoles extends Migration class AddReadonlyToRoles extends Migration

View File

@ -18,7 +18,7 @@ class UsersAddPilotId extends Migration
*/ */
public function up() public function up()
{ {
Schema::table('users', function (Blueprint $table) { Schema::table('users', static function (Blueprint $table) {
$table->unsignedBigInteger('pilot_id') $table->unsignedBigInteger('pilot_id')
->after('id') ->after('id')
->unique() ->unique()
@ -26,8 +26,7 @@ class UsersAddPilotId extends Migration
->index('users_pilot_id'); ->index('users_pilot_id');
}); });
// Migrate the current pilot IDs DB::table('users')->update(['pilot_id' => DB::raw('`id`')]);
DB::update('UPDATE `users` SET `pilot_id`=`id`');
} }
/** /**

View File

@ -16,8 +16,9 @@ class PirepsChangeStateType extends Migration
public function up() public function up()
{ {
// Migrate the old rejected state // Migrate the old rejected state
DB::update('UPDATE `pireps` SET `state`='.PirepState::REJECTED DB::table('pireps')
.' WHERE state=-1'); ->where(['state' => -1])
->update(['state' => PirepState::REJECTED]);
// Change the column type to an unsigned small int (tinyint not supported on all) // Change the column type to an unsigned small int (tinyint not supported on all)
Schema::table('pireps', function (Blueprint $table) { Schema::table('pireps', function (Blueprint $table) {

View File

@ -18,6 +18,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Laracasts\Flash\Flash;
use Modules\Installer\Services\ConfigService; use Modules\Installer\Services\ConfigService;
use Modules\Installer\Services\RequirementsService; use Modules\Installer\Services\RequirementsService;
@ -196,7 +197,7 @@ class InstallerController extends Controller
Log::error('Testing db before writing configs failed'); Log::error('Testing db before writing configs failed');
Log::error($e->getMessage()); Log::error($e->getMessage());
flash()->error($e->getMessage()); Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();
} }
@ -224,7 +225,7 @@ class InstallerController extends Controller
Log::error('Config files failed to write'); Log::error('Config files failed to write');
Log::error($e->getMessage()); Log::error($e->getMessage());
flash()->error($e->getMessage()); Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();
} }
@ -238,7 +239,7 @@ class InstallerController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return mixed
*/ */
public function dbsetup(Request $request) public function dbsetup(Request $request)
{ {
@ -250,9 +251,9 @@ class InstallerController extends Controller
$this->seederSvc->syncAllSeeds(); $this->seederSvc->syncAllSeeds();
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error('Error on db setup: '.$e->getMessage()); Log::error('Error on db setup: '.$e->getMessage());
dd($e);
$this->envSvc->removeConfigFiles(); $this->envSvc->removeConfigFiles();
flash()->error($e->getMessage()); Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();
} }

View File

@ -1,11 +1,19 @@
@foreach (session('flash_notification', []) as $message) @if (session()->has('flash_notification.message'))
<div class="alert alert-danger" role="alert"> @if (session()->has('flash_notification.overlay'))
<div class="container"> @include('flash::modal', [
<div class="alert-icon"> 'modalClass' => 'flash-modal',
<i class="now-ui-icons ui-2_like"></i> 'title' => session('flash_notification.title'),
'body' => session('flash_notification.message')
])
@else
<div class="alert
alert-{{ session('flash_notification.level') }}
{{ session()->has('flash_notification.important') ? 'alert-important' : '' }}">
@if(session()->has('flash_notification.important'))
<button type="button" class="close" data-dismiss="alert">&times;</button>
@endif
{{ session('flash_notification.message') }}
</div> </div>
{{ $message['message'] }} @endif
</div> @endif
</div>
@endforeach
{{ session()->forget('flash_notification') }}

View File

@ -12,9 +12,9 @@
<td>PHP Version: {{ $php['version'] }}</td> <td>PHP Version: {{ $php['version'] }}</td>
<td style="text-align:center;"> <td style="text-align:center;">
@if($php['passed'] === true) @if($php['passed'] === true)
<span class="badge badge-success">OK!</span> <span class="badge badge-success">OK</span>
@else @else
<span class="badge badge-danger">Failed!</span> <span class="badge badge-danger">Failed</span>
@endif @endif
</td> </td>
</tr> </tr>
@ -27,9 +27,9 @@
<td>{{ $ext['ext'] }}</td> <td>{{ $ext['ext'] }}</td>
<td style="text-align:center;"> <td style="text-align:center;">
@if($ext['passed'] === true) @if($ext['passed'] === true)
<span class="badge badge-success">OK!</span> <span class="badge badge-success">OK</span>
@else @else
<span class="badge badge-danger">Failed!</span> <span class="badge badge-danger">Failed</span>
@endif @endif
</td> </td>
</tr> </tr>
@ -46,9 +46,9 @@
<td>{{ $dir['dir'] }}</td> <td>{{ $dir['dir'] }}</td>
<td style="text-align:center;"> <td style="text-align:center;">
@if($dir['passed'] === true) @if($dir['passed'] === true)
<span class="badge badge-success">OK!</span> <span class="badge badge-success">OK</span>
@else @else
<span class="badge badge-danger">Failed!</span> <span class="badge badge-danger">Failed</span>
@endif @endif
</td> </td>
</tr> </tr>
@ -59,9 +59,6 @@
{{ Form::submit('Database Setup >>', ['class' => 'btn btn-success']) }} {{ Form::submit('Database Setup >>', ['class' => 'btn btn-success']) }}
</p> </p>
@endif @endif
{{--{{ $php_version }}
{{ $extensions }}
{{ $passed }}--}}
{{ Form::close() }} {{ Form::close() }}
</div> </div>
@endsection @endsection