mysql - LARAVEL 5.5 Foreign key constraint is incorrectly formed' -


i encountering "errno: 150 'foreign key constraint incorrectly formed'" when migrating.

i have table needs 3 foreign keys:

  schema::create('ads', function (blueprint $table) {         $table->increments('id');         $table->string('prodname');         $table->string('mfrname');         $table->decimal('priceam');         $table->string('imagenametxt',500);         $table->string('specstxt',500);         $table->string('otherinfotxt',500);         $table->decimal('avalableqty');         $table->binary('validyn');         $table->binary('checkyn');         $table->binary('updatedyn');         $table->integer('selleridno')->unsigned();         $table->integer('catidno')->unsigned();         $table->integer('subcatidno')->unsigned();         $table->timestamps();      });      schema::table('ads', function(blueprint $table){         $table->foreign('selleridno')->references('id')->on('users');         $table->foreign('catidno')->references('id')->on('categories');         $table->foreign('subcatidno')->references('id')->           on('subcategories');     }); 

users, categories , subcategories table created before table. selleridno , catidno created in creating foreign key subcatidno encountering error. suggestions/opinions? thank in advance.

my database mysql.

just in case need subcategories table here is:

schema::create('sub_categories', function (blueprint $table) {             $table->increments('id');             $table->string('subcategorycd');             $table->string('subcategorytxt');             $table->integer('categoryidno')->unsigned();             $table->timestamps();              $table->foreign('categoryidno')->references('id')->on('categories');         }); 

this foreign key on table called subcategories:

$table->foreign('subcatidno')->references('id')->on('subcategories'); 

but table called sub_categories:

schema::create('sub_categories', function (blueprint $table) { 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -