Now you can add the column in the database table only if its not present & can drop it if, its present. For that following methods are introduced:
👉 whenTableDoesntHaveColumn
👉 whenTableHasColumn
Available from Laravel 9.6.0
1return new class extends Migration { 2 public function up() 3 { 4 Schema::whenTableDoesntHaveColumn('users', 'name', function (Blueprint $table) { 5 $table->string('name', 30); 6 }); 7 } 8 9 public function down()10 {11 Schema::whenTableHasColumn('users', 'name', function (Blueprint $table) {12 $table->dropColumn('name');13 });14 }15}
Tip given by @iamharis010