How to fix Failed to update columns dictionary object in MySQL 8 with Laravel

December 8, 2022

Recently when upgrading to MySQL 8 at work, we started to run into this error when we would run older migrations.

General error: 3507 Failed to update columns dictionary object.

It turns out that as of MySQL 8, column names are limited to 53 characters. That should always be enough for everyone, but apparently it wasn't for some previous engineers that wrote those column names.

MySQL will happily create the table with a larger column name size and will successfully accept data into it, however if you try to change something about the column or drop it you'll get the above error.

The answer was simple though, rename the column to something more sane before dropping it.

 Schema::table('users', function (Blueprint $table) {
    $table->renameColumn('really_long_column_name_that_probably_shouldnt_be_so_long_but_it_is', 'shorter_column_name');
    
    $table->dropColumn('shorter_column_name');
});

Monitor your DNS Zones with ZoneWatcher

Be alerted of DNS record changes moments after they happen, not from upset customers.

ZoneWatcher screenshot