我创建了两个laavel迁移,第一个运行得很好,第二个给我一个错误:
SQLSTATE[23000]:完整性约束冲突:1452无法添加或 更新子行:外键约束失败
我不知道我的外卡出了什么问题,有人能帮帮我吗?
以下是我的第一个架构:
Schema::create('cryptocurrencies', function (Blueprint $table) {
$table->id('id');
$table->string('name');
$table->string('symbol')->unique();
$table->string('slug');
$table->longtext('description');
});
以下是我的第二个架构:
Schema::create('cryptocurrencies_quotes', function (Blueprint $table) {
$table->id('id');
$table->string('name');
$table->string('symbol');
$table->string('slug');
$table->integer('cryptocurrency_id');
$table->bigInteger('circulating_supply');
$table->bigInteger('total_supply');
$table->double('price');
$table->double('volume_24h');
$table->timestamps();
});
Schema::table('cryptocurrencies_quotes', function (Blueprint $table) {
$table->foreign('cryptocurrency_id')->references('id')->on('cryptocurrencies')->onUpdate('cascade')->onDelete('cascade');
});