Laravel Migrations: Renaming columns in tables with ENUMs

So in working with Laravel’s database migrations feature it appears you can’t rename columns in tables which contain enum columns (the issue is noted in their documentation: Note: Renaming columns in a table with a enum column is not currently supported but can be easily missed)

When you do attempt to migrate it may give you an error as follows:

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

The quick away around it I found, while retaining data, is to run the raw query using the DB::statement function:

DB::statement('ALTER TABLE [table_name] CHANGE [from] [to] [column_definition]'); 

Just make sure you add the reverse query in the down function!


Published by:


Production Facilitator at Audacious Church Previously Software Developer at UKFast Ltd. and Web Applications Developer at SenseLogix Ltd. Graduate of Renewable Energy BSc from the University of Exeter. Experience with PHP, MySQL, Javascript, CSS and HTML.

Categories PHP, Web DevelopmentLeave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s