Laravel db migration - renameColumn error - Unknown database type enum requested

前端 未结 8 844
暗喜
暗喜 2020-12-10 11:53

I am using Laravel 4.2. I have the following library loaded in my composer.json

\"doctrine/dbal\": \"2.4.*\",

I c

相关标签:
8条回答
  • 2020-12-10 12:19
    DB::getDoctrineSchemaManager()
        ->getDatabasePlatform()
        ->registerDoctrineTypeMapping('enum', 'string');
    

    This works for me on Laravel 5.1

    0 讨论(0)
  • 2020-12-10 12:25

    Here is the answer for Laravel 5.2.45+ (might work in 5.1 as well, have not tested or checked yet, please let me know so I can update this question.)

    Add this line in your up method:

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

    Something like this:

    public function up()
    {
        Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
        Schema::table('users', function (Blueprint $table) {
             $table->text('bio')->change();
        });
    }
    
    0 讨论(0)
提交回复
热议问题