column exist but when migration it returns
SQLSTATE[42000]: Syntax error or access violation: 1072 Key column doesn't exist in table
when i remove foreign key the problem is solved
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function up()
{
Schema::create('skills', function (Blueprint $table) {
$table->increments('id');
$table->string('skill_name')->nullable();
$table->decimal('skill_note')->nullable();
$table->timestamps();
});
}
public function up()
{
Schema::create('skill_user', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->foreign('user_id ')
->references('id')->on('users');
$table->unsignedInteger('skill_id');
$table->foreign('skill_id')
->references('id')->on('skills');
$table->decimal('note')->nullable();
$table->timestamps();
});
}
In version 6 (the one you're using for what I could read in the comments), the increments('id') method doesn't create a Unsigned Integer, it rather creates a Unsigned Big Integer, therefore you need to change your foreign keys to
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('skill_id');
Try this once.
$table->integer('user_id')->unsigned(); $table->integer('skill_id')->unsigned();
If it does not work, I would suggest to run composer install and migrate:fresh
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.