【发布时间】:2016-09-17 18:36:02
【问题描述】:
我有以下迁移:
Schema::create('tags', function (Blueprint $table) {
$table->increments('id')->unsigned()->index();
$table->string('name',30);
$table->integer('parent_id')->nullable();
$table->string('image_url');
$table->string('image_id',50);
$table->timestamps();
$table->foreign('parent_id')
->references('id')->on('tags')
->onDelete('cascade');
});
出现以下问题:
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alte
r table `tags` add constraint `tags_parent_id_foreign` foreign key (`parent_id`) references `tags` (`id`) on delete cascade)
一切都很好。我检查了很多,但没有工作。
以下问题对我不起作用。我不知道为什么,这个问题没有解决我的问题。
【问题讨论】: