Laravel - How to remove foreign key constraint using migration?

By Hardik Savani | July 1, 2016 | | 47036 Viewer | Category : Laravel

Sometimes it can be agreeable to remove a database column that hosts a foreign key relationship, and we add wrong column with foreign key constraint on table, At that time we must remove that column from table.

But we can't remove directly using dropColumn() because we did apply foreign key constraint so we should drop foreign key constraint of that column using dropForeign() and then we can delete column using dropColumn(). You can see as bellw migration, first i added migration with wrong column then other migration for remove that column.

Wrong Column Migration:

Schema::create('admins', function (Blueprint $table) {





$table->string('password', 60);





Drop Column Migration:

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




***Do you want me hire for your Project Work? Then Contact US.