Web Prepration

Web Concept Tutorials


In this post, I am going to explain How to remove foreign key constraint and database column that hosts a foreign key relationship, and we add wrong column with foreign key constraint on table. here, we will remove foreign key constraint using migration in laravel 6, laravel 7 and laravel 8.

We can’t remove directly using dropColumn() if column applied 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:

Drop Column Migration:


0 comment on Laravel – How to remove foreign key constraint using migration?

Write a comment

Your email address will not be published. Required fields are marked *