Skip to content

Commit

Permalink
Fix migrations when table prefix is involved #442 (#555)
Browse files Browse the repository at this point in the history
* Fix migrations when table prefix is involved #442

* Formatting
  • Loading branch information
nabeelio authored Feb 18, 2020
1 parent 2d36376 commit 8300a69
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 30 deletions.
3 changes: 2 additions & 1 deletion app/Contracts/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Laracasts\Flash\Flash;

/**
* Class Controller
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ 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()
->nullable()
->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`')]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions modules/Installer/Http/Controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;

Expand Down Expand Up @@ -196,7 +197,7 @@ public function envsetup(Request $request)
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();
}

Expand Down Expand Up @@ -224,7 +225,7 @@ public function envsetup(Request $request)
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();
}

Expand All @@ -238,7 +239,7 @@ public function envsetup(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)
{
Expand All @@ -250,9 +251,9 @@ public function dbsetup(Request $request)
$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();
}

Expand Down
28 changes: 18 additions & 10 deletions modules/Installer/Resources/views/flash/message.blade.php
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -59,9 +59,6 @@
{{ Form::submit('Database Setup >>', ['class' => 'btn btn-success']) }}
</p>
@endif
{{--{{ $php_version }}
{{ $extensions }}
{{ $passed }}--}}
{{ Form::close() }}
</div>
@endsection

0 comments on commit 8300a69

Please sign in to comment.