![](/img/trans.png)
[英]SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'proform_id' doesn't exist in table
[英]column exist but when migration it returns SQLSTATE[42000]: Syntax error or access violation: 1072 Key column doesn't exist in table
列存在但迁移时返回
SQLSTATE[42000]:语法错误或访问冲突:1072 表中不存在键列
当我删除外键时,问题就解决了
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();
});
}
在第 6 版(您用于我在评论中读到的内容的那个)中, increments('id') 方法不会创建无符号整数,而是创建一个无符号大整数,因此您需要更改您的外键
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('skill_id');
试试这个。
$table->integer('user_id')->unsigned(); $table->integer('skill_id')->unsigned();
如果它不起作用,我建议运行 composer install 和 migrate:fresh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.