Laravel migration change foreign id to be nullable

If you created a foreign key in your database which should have been nullable, you have to create a database migration to fix that.

To make your foreign key nullable, you first need to delete the Foreign Key constraint, then change the field to be nullable and then create the Foreign Key constraint again.


return new class extends Migration {
    public function up(): void
        Schema::table('retailers', function (Blueprint $table) {



Click Here to Leave a Comment Below

Leave a Reply: