Support the ongoing development of →
Database Eloquent Installation
Last updated 1 year ago.

Generally that means a type error between the two columns. I think there is a problem is the "models" table as the user_id on it might not be unsigned because there's a spelling error on the "->unsigned()" which would prevent it from being an unsigned int like on the "model_photosets" table. Check your database to confirm if you have the right data type on the models table.


rowright said:

Thanks for the answer. I tried to correct the spelling error in the type name (table models) and completely remove it, but it did not help me :c

Last updated 6 years ago.


Follow below steps:

  1. Run migration first for 'photoset_categories' and 'models'
  2. Run migration for 'model_photosets' once above step 1) migration done

Here, the problem is your 'model_photosets' table migration run before the foreign key table migration(i.e. 'photoset_categories' and 'models')

Hope this works for you!


saurabhd said:

Hi! Thanks for the answer. I did everything as you said, but the error remained. I noticed a feature: when I change foreign key user_id to id it works. But this is not what I need.


Use below code in your CreateModelPhotosetsTable migration file

class CreateModelPhotosetsTable extends Migration
    * Run the migrations.
    * @return void
   public function up()
       Schema::create('model_photosets', function (Blueprint $table) {


Hope this work for you !


Sign in to participate in this thread!


Your banner here too?

MyZik myzik Joined 16 Apr 2017


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.