我正在尝试将我的新架构转发到我的数据库服务器上,但我无法弄清楚为什么我收到此错误。我试图在这里搜索答案,但我发现的所有内容都说要么将数据库引擎设置为Innodb,要么确保我尝试用作外键的密钥是他们自己的表中的主键。有些人说这两列的数据类型不同,但我确保两种列数据类型都相同。如果我没弄错的话,我已经完成了这两件事。你们可以提供任何其他帮助吗?
users表迁移代码:
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->unsignedBigInteger('batch_id')->nullable()->default(0);
$table->rememberToken();
$table->unsignedInteger('create_at')->nullable()->default(0);
$table->foreign('batch_id')->references('id')->on('batches')->onUpdate('cascade')->onDelete('cascade');
});
批处理表迁移代码:
Schema::create('batches', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->string('name',200)->unique();
$table->unsignedInteger('create_at')->nullable()->default(0);
});