From Laravel 8.27 you can add multiple new columns after an existing column at the same time.
In previously, it isnβt difficult to write, youβd have to call after() method for each subsequent new column.
Schema::table('customers', function ($table) {
$table->string('address_line1')->after('password');
$table->string('address_line2')->after('address_line1');
$table->string('city')->after('address_line2');
});
From version 8.27 you can group them in a new after() method on the Blueprint migration instance.
Schema::table('customers', function ($table) {
$table->after('password', function ($table) {
$table->string('address_line1');
$table->string('address_line2');
$table->string('city');
});
});
Happy Coding:)
Top comments (0)