0
我想为我的外键有一个自定义名称。我能怎么做 ? 我使用下面的代码,但它让我错误:语法错误或访问冲突:1072键列 - 自我加入
SQLSTATE [42000]:语法错误或访问冲突:1072键列 'parent_section_id' 不表(SQL存在:ALTER TABLE
sections
加约束sections_parent_section_id _foreign
外键(parent_section_id
)上 删除级联引用sections
(id
))
我想要的东西:
id
- title
- parent_section_id
parent_section_id
参考电流id表
public function up()
{
Schema::create('sections', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->foreign('parent_section_id')->references('id')->on('sections')->onDelete('cascade');
$table->timestamps();
});
}