shubhangi's avatar

Laravel Foreign Key Error

I Have thetablecalledUsers

USERS Table Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); public function down() { Schema::dropIfExists('users'); }

I want to add foreign key into company table,but i am getting following Error:

1005: "Foreign key constraint is incorrectly formed"

Company Table public function up() { // Schema::create('companies', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->LongText('description'); $table->integer('user_id')->unsinged(); $table->foreign('user_id')->references('id')->on('users'); $table->timestamps(); }); }

public function down() { // Schema::dropIfExists('companies'); }

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

user_id column is unsinged instead of unsigned

1 like

Please or to participate in this conversation.