Fixing some column editing problems in Laravel Migrations

I faced this problems while I was rewriting file section of my blog. At first, I meant to use files only for blog, but recently I decided to create portfolio section which will also use uploaded files so the easiest way to do this was to add type column and map with other tables by id.

The first error came during the renaming

$table->renameColumn('post_id', 'parent_id');
[Symfony\Component\Debug\Exception\FatalErrorException] Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

To solve this problem you need to add dbal package as it not included in Laravel by default (only suggested). To add it simply run this command: composer require doctrine/dbal

The second error came during the dropping

$table->dropColumn('type');
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

In this case there is Doctrine Cookbook article. All you need to do is register the ENUM type as a Doctrine string type:

DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
Fork me on GitHub