Good day,
I am trying to drop a foreign key in a Laravel 5.2 migration previously implemented like this:
EDIT: The creation of the id in the table (before using foreign key on it) was:
$table->integer('agent_rights_id')->unsigned()->nullable();
The foreign key:
Schema::table('agents', function (Blueprint $table){
$table->foreign('agent_rights_id')->references('id')->on('agent_rights');
});
My drop looks like this:
Schema::table('agents', function (Blueprint $table){
$table->dropForeign('agents_agent_rights_id_foreign');
$table->dropColumn('agent_rights_id');
});
I found out, that one must take the "real" index name and not the label - this I have already thought of in the previous snippet (as a reference to this question).
But this gives me the errors:
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1025 Error on rename of './{name}/agents' to './{name}/#sql2-2a6-1d8' (errno: 152) (SQL: alter table `agents` drop foreign key `agents_agent_rights_id_foreign`)
[PDOException]
SQLSTATE[HY000]: General error: 1025 Error on rename of './{name}/agents' to './{name}/#sql2-2a6-1d8' (errno: 152)
Researching this brings up no real solutions, only bug messages from MySQL...
Question: Do you guys anything about this, or what was wrong with my snippet?