Skip to content

Commit fff0e16

Browse files
Fixes #80 : foreign key error message in migration now compatible with 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
1 parent 53009ab commit fff0e16

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

database/migrations/2018_06_29_032244_create_laravel_follow_tables.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ public function up()
2121
{
2222
Schema::create(config('follow.followable_table', 'followables'), function (Blueprint $table) {
2323
$userForeignKey = config('follow.users_table_foreign_key', 'user_id');
24-
$table->unsignedInteger($userForeignKey);
24+
25+
// Laravel 5.8 session user is unsignedBigInteger
26+
// https://github.com/laravel/framework/pull/28206/files
27+
if ((float) app()->version() >= 5.8) {
28+
$table->unsignedBigInteger($userForeignKey);
29+
} else {
30+
$table->unsignedInteger($userForeignKey);
31+
}
32+
2533
$table->unsignedInteger('followable_id');
2634
$table->string('followable_type')->index();
2735
$table->string('relation')->default('follow')->comment('follow/like/subscribe/favorite/upvote/downvote');

0 commit comments

Comments
 (0)