dengdeng's avatar

Failed to rename a column in a migration.

I do have an enum column in database. But i didn't touch it anymore. I just rename a string type 'name' column to new name. And i got this error:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

I searched it in google. This issue happened several years ago. Why didn't fix it? And what should i do to fix it?

0 likes
4 replies
Snapey's avatar

what does your migration file look like?

hlgrrnhrdt's avatar

It's a known and 4 years old bug in Doctrine DBAL. It will also happen when there is a json field in the table.

You have to put

Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');

Before Schema::table()

See for reference https://github.com/laravel/framework/issues/1186

jasperstaats's avatar

We had the same problem but we just did it with a raw DB statement in the migration at the up()

 DB::statement("ALTER TABLE tablename CHANGE columnname columnnamenew ENUM('string1','string2','string3');");

I hope this helps.

Please or to participate in this conversation.