Framework: [L5] [Doctrine\DBAL\DBALException when trying to change a decimal column

Created on 29 May 2015  路  4Comments  路  Source: laravel/framework

I tried to change the size of a decimal column from 8,2 to 15,3:

Schema::table('table_name', function ($table) {
    $table->double('length',15,3)->change();
});

I'm getting a weird exception message:

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

Most helpful comment

You can either use float instead double setence:.

Change this

$table->double('length',15,3)->change();

By this

$table->float('length',15,3)->change();

All 4 comments

Is still an issue in the very latest release. I thought I fixed this?

Yes it is in the latest release, have this problem in current project.

@grahamcampbell @soee: this is no issue of Laravel but rather Doctrine. If Doctrine is available, it is used for all migrations, and Doctrine does not support enums. Since the Schema builder accesses the entire table with Schema::table, it fails if the table has one or more enum columns, regardless of if that column is being changed or not.

Very late edit: for those that do get this exception, you can add the following line of code your migration:

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

A more proper solution is mentioned in https://github.com/laravel/framework/issues/1186#issuecomment-118194746.

This workaround here is simple, it tells doctrine enums are strings, but will not work for changing actual enum columns. To change those, you'll want to use the proper solution, which is to register a custom enum type for that particular enum.

You can either use float instead double setence:.

Change this

$table->double('length',15,3)->change();

By this

$table->float('length',15,3)->change();
Was this page helpful?
0 / 5 - 0 ratings