【发布时间】:2021-07-01 04:07:53
【问题描述】:
我对 Laravel 迁移有一些小问题。我有一张自己有父行的表,当我尝试安装护照时,护照正在回滚迁移,其中一个会出现以下问题:
SQLSTATE[23000]:违反完整性约束:1451 无法删除或 更新父行:外键约束失败(SQL:drop table 如果存在
e_categories)
表格如下:
Schema::create('e_categories', function (Blueprint $table) {
$table->uuid('id');
$table->primary('id');
$table->string('name');
$table->uuid('parent_id')->nullable();
$table->foreign('parent_id')->references('id')->on('e_categories')->onDelete('cascade');
$table->timestamps();
});
向下
Schema::dropIfExists('e_categories');
顺便说一句,在此迁移中存储了其他类别的迁移,但这个是一个问题。
【问题讨论】: