Search code examples
phplaravellaravel-4laravel-5

Laravel 5.1 Unknown database type enum requested


While running php artisan migrate, I got the following error

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

How to resolve this issue.

Code:

public function up() {
    Schema::table('blogs', function (Blueprint $table) {
        $table->string('wordpress_id')->nullable();
        $table->string('google_blog_id')->nullable()->change();
    });
}

Solution

  • The official Laravel 5.1 documentation states:

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

    It doesn't matter if you're trying to change another column, if the table contains a enum anywhere it won't work. It's a Doctrine DBAL issue.

    As a workaround you could either drop the column and add a new one (column data will be lost):

    public function up()
    {
        Schema::table('users', function(Blueprint $table)
        {
            $table->dropColumn('name');
        });
    
        Schema::table('users', function(Blueprint $table)
        {
            $table->text('username');
        });
    }
    

    or use a DB statement:

    public function up()
    {
        DB::statement('ALTER TABLE projects CHANGE slug url VARCHAR(200)');
    }
    
    public function down()
    {
        DB::statement('ALTER TABLE projects CHANGE url slug VARCHAR(200)');
    }
    

    Source: https://github.com/laravel/framework/issues/1186