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\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Laracasts\Flash\Flash;
/**
* Class Controller
@ -26,7 +27,7 @@ abstract class Controller extends \Illuminate\Routing\Controller
*/
public function flashError($message, $route)
{
flash()->error($message);
Flash::error($message);
return redirect(route($route))->withInput();
}

View File

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

View File

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

View File

@ -16,8 +16,9 @@ class PirepsChangeStateType extends Migration
public function up()
{
// Migrate the old rejected state
DB::update('UPDATE `pireps` SET `state`='.PirepState::REJECTED
.' WHERE state=-1');
DB::table('pireps')
->where(['state' => -1])
->update(['state' => PirepState::REJECTED]);
// Change the column type to an unsigned small int (tinyint not supported on all)
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\Log;
use Illuminate\Support\Facades\Validator;
use Laracasts\Flash\Flash;
use Modules\Installer\Services\ConfigService;
use Modules\Installer\Services\RequirementsService;
@ -196,7 +197,7 @@ class InstallerController extends Controller
Log::error('Testing db before writing configs failed');
Log::error($e->getMessage());
flash()->error($e->getMessage());
Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput();
}
@ -224,7 +225,7 @@ class InstallerController extends Controller
Log::error('Config files failed to write');
Log::error($e->getMessage());
flash()->error($e->getMessage());
Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput();
}
@ -238,7 +239,7 @@ class InstallerController extends Controller
*
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @return mixed
*/
public function dbsetup(Request $request)
{
@ -250,9 +251,9 @@ class InstallerController extends Controller
$this->seederSvc->syncAllSeeds();
} catch (QueryException $e) {
Log::error('Error on db setup: '.$e->getMessage());
dd($e);
$this->envSvc->removeConfigFiles();
flash()->error($e->getMessage());
Flash::error($e->getMessage());
return redirect(route('installer.step2'))->withInput();
}

View File

@ -1,11 +1,19 @@
@foreach (session('flash_notification', []) as $message)
<div class="alert alert-danger" role="alert">
<div class="container">
<div class="alert-icon">
<i class="now-ui-icons ui-2_like"></i>
</div>
{{ $message['message'] }}
@if (session()->has('flash_notification.message'))
@if (session()->has('flash_notification.overlay'))
@include('flash::modal', [
'modalClass' => 'flash-modal',
'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>
@endforeach
{{ session()->forget('flash_notification') }}
@endif
@endif

View File

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