[Solved] SQLSTATE[HY000]: General error: 1824 Failed to open the referenced table (alter on Foreign key) Laravel
I was facing this issue since 3 days and i’d like to share the solution,
the solution was by converting the type of sql engine in the table using the following code<?php
$table->engine = 'InnoDB';
?>
so the Schema
function of the table should be like this <?php
public function up(){
Schema::create('posts', function (Blueprint $table) {
$table->engine = 'InnoDB'; //Add this line
$table->bigIncrements('id');
$table->string('title');
$table->string('post_url');
$table->string('img_path')->nullable();
$table->longtext('content');
$table->unsignedBigInteger('ownerID');
$table->foreign('ownerID')->references('id')->on('admins')->onDelete('cascade');
$table->timestamps();
});
}
?>