hello , I have this migration -
Schema::create('my_table', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('post_id')->unsigned();
$table->foreign('post_id')->references('id')->on('prop_new')->onDelete('cascade');
$table->string('title', 255);
$table->unique(['post_id','title']);
});
public function down()
{
Schema::table('my_table', function(Blueprint $table){
$table->dropForeign('my_table_post_id_foreig');
});
Schema::dropIfExists('my_table');
}
}
Laravel creates a unique key in for post_id and title , called -
my_table_post_id_title_unique
in table - my_table .
If you go to phpmyadmin when you migrate this , you gonna see this key there , on Indexes .
I tried to delete this unique key index . but I am not able . it says this message -
#1553 - Cannot drop index 'my_table_post_id_title_unique': needed in a foreign key constraint
I tried as well make those commands in mysql -
ALTER TABLE `my_table` DROP INDEX `my_table_post_id_title_unique`;
or
DROP INDEX `my_table_post_id_title_unique` ON `my_table`
But I was no success , I cant drop the unique index key .