Only until March 18th: coupon LARAVEL12 for 40% off Yearly/Lifetime membership!

Read more here

Anonymous Migrations

The Laravel team released Laravel 8.37 with anonymous migration support, which solves a GitHub issue with migration class name collisions. The core of the problem is that if multiple migrations have the same class name, it'll cause issues when trying to recreate the database from scratch. Here's an example from the pull request tests:

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
 
return new class extends Migration {
public function up(
{
Schema::table('people', function (Blueprint $table) {
$table->string('first_name')->nullable();
});
}
 
public function down()
{
Schema::table('people', function (Blueprint $table) {
$table->dropColumn('first_name');
});
}
};

Tip given by @nicksdot

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 71 courses
  • 93 long-form tutorials
  • access to project repositories
  • access to private Discord

Recent New Courses