Web Prepration

Web Concept Tutorials

Laravel

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:

  WebpreprationI’m a full-stack developer.  My hobby and profession to write blog and programming tips that helps to others. I am a great admirer of PHP, Laravel, Codeigniter, AngularJS,  Vue.js,  Javascript, JQuery, WordPress, Plugin Development, Theme Development and Bootstrap

read more >>