Menu

I Broke One Laravel Migration on MySQL, PostgreSQL and SQLite. What MigrationFailed in 13.42 Changes
📰

I Broke One Laravel Migration on MySQL, PostgreSQL and SQLite. What MigrationFailed in 13.42 Changes

DEV Community: laravel·Hafiz·about 18 hours ago
#EBWAiQMg
#devtolaravel#devto#dev#migration#table
Reading 0:00
15s threshold

Originally published at hafiz.dev

You fix the duplicate data, run php artisan migrate again, and Laravel answers with Duplicate column name 'slug' . The migration failed the first time, so Laravel never recorded it. But half of it ran anyway, and now that half blocks the retry.

Laravel 13.42 added a MigrationFailed event for this exact moment ( PR #62342 , from Jack Bayliss). It fires when a migration throws and carries the exception. The release write-up on Laravel News suggests using it to alert your team before users hit a half-applied schema.

So which databases actually leave one behind? I ran the same failing migration on MySQL 8.4.13, PostgreSQL 17.12 and SQLite 3.53.4 (the version bundled with PHP 8.4 on my Mac), all on Laravel 13.42.0. They didn't all leave the same mess behind.

The migration that fails halfway

It's the classic slug migration.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.