laravel-doctrine/migrations

Column collation in schema builder

fpolli opened this issue · 3 comments

Am I just missing it or is there no way to set the collation on a column other than using addSQL and defining the column manually? I need to set the collation (MySQL) on a varchar column to utf8mb4_bin and I see no option corresponding to Laravel's collation() method or even any way to add it in an options array.

that would be a question to google around for doctrine mappings and collation its related to laravel-doctrine/migrations

or posible Doctrine\DBAL\Schema\Column

For anyone who might have the same issue in the future, the way to do this is to use the addColumn method on the underlying DBAL Table class, and use the 'customSchemaOptions' field in the options array. Note: apparently customSchemaOptions is deprecated in DBAL and in the future you will have to use customPlatformOptions, but laravel-doctrine apparently uses an older version. The code is:

        $table->getTable()->addColumn('plan_id', 'string', [
          'length' => 255,
          'customSchemaOptions' => [
            'collation' => 'utf8mb4_bin'
          ]
        ]);

thanks for the link dpslwk. Between that and the DBAL and migrations code on Github, I was able to figure it out