I have the following migration :
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');
});
The following issue comes up:
(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)
Everything is good. I have checked alot but not working.
The following question is not working for me. I don't know why, That question is not addressing my issues.