5
votes

I am using Laravel and I have migration with function:

public function up()
{
    Schema::table('articles', function (Blueprint $table) {
        $table->string('article_title',100)->change();
    });
}

and when i do 'php artisan migrate' on my cmd i get error:

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

I don't even use enum! And I also don't have any other migrations that are not migrated and have enum.

3
Did you create this table before ? If not, you need to create it Schema::create('articles', function (Blueprint $table) { $table->string('article_title',100)->change(); }); - Trong Lam Phan
i have this table and also have this column, but want to change length from 50 to 100 :) - Danielius

3 Answers

1
votes

I believe I've had this issue before. The problem is that the Schema class provided to the database migration factory is actually an abstraction of the Doctrine\DBAL\Schema class, and not a direct duplication.

When you first ran composer install, there were several "recommended" dependencies that you should install. No one ever does, but eventually you might find some small bug and spend hours on it, only to realize Hey...Maybe I should try those other optional dependencies?

Don't be like me. Instead, try what I've outlined below.

You need to directly add "doctrine/dbal": "^2.5", (or whatever stable version exists at the time of reading) to your composer.json file under "require": {.

Once you've added that line, do a composer update, and then add this line to your migration:

use Doctrine\DBAL\Schema\Schema

After doing this, you shouldn't see that error anymore.

3
votes

The column itself does not have to be enum, but ANY column in the table cannot be enum.

Here is the line from the renaming columns section of the Laravel documentation:

Note: Renaming columns in a table with a enum column is not currently supported.

-1
votes

Link to the documentation of Laravel: Changing columns. You need to add doctrine/dbal to your composer.json file.

Note: Before changing a column, be sure to add the doctrine/dbal dependency to your composer.json file.

Or run this command:

composer require doctrine/dbal