Migratie Laravel - Eroare Foreign Key

Am luat un pachet, nu pot rula migratiile, sunt 2 migratii. Prima pare sa fie ok, a2-a nu.
Eroare: 1

Prima migratie:

public function up()
{
    $tableName = 'comments';

    Schema::create($tableName, function (Blueprint $table) use ($tableName) {
        $table->increments('id');
        $table->unsignedInteger('commentable_id')->nullable();
        $table->string('commentable_type')->nullable();
        $table->index(['commentable_id', 'commentable_type']);
        $table->string('page_id')->index()->nullable();
        $table->integer('user_id')->unsigned()->nullable();
        $table->string('author_name')->nullable();
        $table->string('author_email')->nullable();
        $table->string('author_url')->nullable();
        $table->string('author_ip')->nullable();
        $table->string('user_agent')->nullable();
        $table->text('content');
        $table->string('permalink')->nullable();
        $table->integer('upvotes')->default(0);
        $table->integer('downvotes')->default(0);
        $table->enum('status', ['approved', 'pending', 'spam', 'trash'])->default('approved');
        $table->integer('root_id')->unsigned()->index()->nullable();
        $table->integer('parent_id')->unsigned()->index()->nullable();
        $table->timestamps();

        $table->foreign('root_id')
                ->references('id')
                ->on($tableName)
                ->onDelete('cascade');

        $table->foreign('parent_id')
                ->references('id')
                ->on($tableName)
                ->onDelete('cascade');
    });
}

A2-a:

public function up()
{
    Schema::create('comment_votes', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('comment_id')->unsigned();
        $table->integer('user_id')->unsigned();
        $table->enum('type', ['up', 'down'])->default('up');
        $table->timestamps();

        $table->foreign('comment_id')
                ->references('id')
                ->on('comments')
                ->onDelete('cascade');

        $table->foreign('user_id')
                ->references('id')
                ->on((new Comment::$userModel)->getTable())
                ->onDelete('cascade');
    });
}

In cazul tau si cheia primara si foreign key ar trebui sa fie de acelasi tip. Cel putin asa zice mai jos.

In cazul tau poate merge

$table->unsignedBigInteger('comment_id');

Daca pachetul ala este pe Github, vezi si sectiunea de issue-uri. Poate a mai avut cineva problema.

Daca nu merge, poate iti raspunde cineva mai experimnetat in Laravel :slight_smile:

Tot nu merge… dar apreciez mult dorinta de a ma ajuta.

Migratiile le rulezi in fisiere separate? Am incercat sa rulez migratiile pe o instalare curata de Laravel si au functionat. Migratiile rulate sunt exact cele postate de tine.

Cred ca problema e la user_id. Campul id din tabela users e de tip unsignedBigInteger incepand cu Laravel 5.8, dar in migrarea pentru tabela comment_votes, user_id e trecut doar ca unsignedInteger, de unde si eroarea.

Deci poti incerca $table->unsignedBigInteger('user_id');