Skip to content

Commit

Permalink
Fixes #80 : foreign key error message in migration now compatible wit…
Browse files Browse the repository at this point in the history
…h Laravel 5.8

* Checks laravel version in migration file and chooses between unsignedInteger or unsignedBigInteger
* [5.8] Change session's user_id to unsigned big integer
* https://github.com/laravel/framework/pull/28206/files
  • Loading branch information
kevincobain2000 committed May 26, 2019
1 parent 53009ab commit fff0e16
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public function up()
{
Schema::create(config('follow.followable_table', 'followables'), function (Blueprint $table) {
$userForeignKey = config('follow.users_table_foreign_key', 'user_id');
$table->unsignedInteger($userForeignKey);

// Laravel 5.8 session user is unsignedBigInteger
// https://github.com/laravel/framework/pull/28206/files
if ((float) app()->version() >= 5.8) {
$table->unsignedBigInteger($userForeignKey);
} else {
$table->unsignedInteger($userForeignKey);
}

$table->unsignedInteger('followable_id');
$table->string('followable_type')->index();
$table->string('relation')->default('follow')->comment('follow/like/subscribe/favorite/upvote/downvote');
Expand Down

0 comments on commit fff0e16

Please sign in to comment.