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
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses
Laravel 13 Eloquent: Expert Level
41 lessons
1 h 34 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read
Laravel Coding with AI Agents: Cursor, Claude Code, Codex
5 lessons
1 h 01 min