Foreign Key Constraint incorrectly formed.

Posted 4 months ago by gouseferoz

I am trying to add a foreign key cascade in migrations and for some reasons it is not working.

I tried to find the issue but no luck.

Schema::create('module_para', function (Blueprint $table) {
            $table->increments('id');
            $table->longText('module');
            $table->timestamps();
        });
Schema::create('module_text', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger("para_id")->default(0);
            $table->longText('explanation')->nullable();
            $table->timestamps();
            $table->foreign('para_id')->references('id')->on('module_para')->onDelete('cascade');
        });

Can you help me in resolving this issue?

Please sign in or create an account to participate in this conversation.