我有2张桌子。我的代码在laravel 5.7上工作得很好但是当我使用laravel时。我总是得到这样的错误。有人可以帮帮我吗?
Schema::create('tb_satuan', function (Blueprint $table) {
$table->bigIncrements('id_satuan');
$table->string('nama_satuan',40);
$table->timestamps();
});
Schema::create('tb_user', function (Blueprint $table) {
$table->bigIncrements('id_user');
$table->BigInteger('id_satuan')->unsigned();
$table->string('username',20);
$table->string('email',30);
$table->text('password');
$table->timestamps();
$table->foreign('id_satuan')->reference('id_satuan')->on('tb_satuan');
});
这是错误:
Illuminate \ Database \ QueryException:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法中有错误;检查与您的MariaDB服务器版本对应的手册,以便在第1行的')'附近使用正确的语法(SQL:alter table
tb_user
add constrainttb_user_id_satuan_foreign
foreign key(id_satuan
)referencestb_satuan
())
这是参考而不是参考
$table->foreign('id_satuan')->references('id_satuan')->on('tb_satuan');