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
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) {