Drop MySQL Primary Key with Foreign Key using Laravel 4 (error 1025 & 105)

This issue is really not specifically related to Laravel. But the code below shows how to handle the issue within Laravel 4.

The issue comes from trying to delete a primary key that's also a foreign key. MySQL would spit out the following "useful" error:

SQLSTATE[HY000]: General error: 1025 Error on rename of './database/#sql-10e9_9c' to './database/table' (errno: 150) (SQL: alter table `table` drop primary key)

To solve this you just need to delete the foreign key first and then the primary key.

Schema::table('products_fulltext', function(Blueprint $table) {

comments powered by Disqus