Changing enum column in Laravel migration

Share on facebook
Share on twitter
Share on linkedin

Changing enum type columns is currently not supported in Laravel, and if you try to run something like:

You are about to get following exception:

Doctrine\DBAL\DBALException : Unknown database type enum requested, Doctrine\DBAL\Platforms\MariaDb1027Platform may not support it.

at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:436
433| $dbType = strtolower($dbType);
435| if (! isset($this->doctrineTypeMapping[$dbType])) {
436| throw new DBALException(‘Unknown database type ‘ . $dbType . ‘ requested, ‘ . static::class . ‘ may not support it.’);
437| }
439| return $this->doctrineTypeMapping[$dbType];
440| }

Exception trace:

1 Doctrine\DBAL\Platforms\AbstractPlatform::getDoctrineTypeMapping(“enum”)

2 Doctrine\DBAL\Schema\MySqlSchemaManager::_getPortableTableColumnDefinition()

Currently there is no legal solution for this problem except avoiding enums, but there is workaround:

Create migration with following

And that will do the trick with enum update you are looking for.

Additionally you can create handle down functions to revert field status as it used to be:



Subscribe to our newsletter

Be first to read new helpful post

Share this post with your friends

Share on linkedin
Share on xing
Share on twitter
Share on facebook
composer Blog Title Image

10 Tips for PHP Composer

  1. Add the composer.lock and the composer.json to Git.

Composer install will install all the packages you have defined in your composer.lock file.

Leave a Reply

Notify of